1

I have a drawable that I would like to render in different sizes on the fly, as opposed to setting the size in layout file. How might I do that? I am referring to the call

imageView.setImageResource(R.drawable.image);
Katedral Pillon
  • 14,534
  • 25
  • 99
  • 199

1 Answers1

0

Decode the resource as a bitmap with a resolution (and other options) specified, then tell the ImageView to show the bitmap:

BitmapFactory.Options options = new BitmapFactory.Options();
options.outHeight = XXXX;
options.outWidth = XXXX;
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.id.myimage, options);

imageView.setImageBitmap(bm);
Victor KP
  • 437
  • 3
  • 10