public Bitmap getBitmapFromDrawable (@DrawableRes int resId){
// create bitmap
Drawable d =ContextCompat.getDrawable(getContext(),res);
Bitmap bmp = Bitmap.createBitmap(d.getIntrinsicWidth(),
d.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmp);
d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
d.draw(canvas);
return bmp;
}
If you want to scale bitmap add this line to the method :
//with x and y as your new width and height
Bitmap newBitmap = Bitmap.createScaledBitmap (bmp,x,y,false);
then:
yourimageview.setImageBitmap(getBitmapFromDrawable(R.drawable.your_drawable));