1

I want to creat a bit map in the size that fill parent of the app window. how can i do that?

Bitmap maskImage =  BitmapFactory.decodeResource(getResources(), R.drawable.img);

ImageView on = (ImageView) findViewById(R.id.on);
Bitmap result = Bitmap.createBitmap(maskImage.getWidth(), maskImage.getHeight(), Bitmap.Config.ARGB_8888);
on.setImageBitmap(result);
Alex K
  • 8,269
  • 9
  • 39
  • 57
sara sara
  • 47
  • 9

1 Answers1

1

Only a single additional line is needed:

Once you have your ImageView:

ImageView on = (ImageView) findViewById(R.id.on);
on.setImageBitmap( . . . );
on.setScaleType(ScaleType.FIT_XY);

ScaleTypes are options for scaling the bounds of your image. You can read more about ScaleTypes in the official docs.

Alex K
  • 8,269
  • 9
  • 39
  • 57
  • but it dosent work and dident fit the the sreen. when I idd this pic from drawble it fits the screen. but when I add given bitmap it dosent fit. – sara sara Oct 04 '15 at 09:21