Axonshi 123
Axonshi 123

Reputation: 123

Drawable gets stretched to fit the view

I'm trying to set a Bitmap Drawable as the background like this, root.setBackground(bitmapDrawable);, I've set its bounds to be 1080 wide by 300 high, but it keeps stretching to fit the entire background. Is there any way to avoid this? This is how i created the BitmapDrawable BitmapDrawable bitmapDrawable= new BitmapDrawable(getResources(), bmp1);

Upvotes: 2

Views: 225

Answers (1)

Bryan
Bryan

Reputation: 15135

I believe the default Gravity of a BitmapDrawable is FILL. Try setting the Gravity to CENTER:

bitmapDrawable.setGravity(Gravity.CENTER);

Upvotes: 2

Related Questions