Axonshi 123 Axonshi 123 - 2 years ago 90
Android Question

Drawable gets stretched to fit the view

I'm trying to set a Bitmap Drawable as the background like this,

, 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= new BitmapDrawable(getResources(), bmp1);

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download