In my XML file, I'm using bitmap as the following
<bitmap android:src="@drawable/Icon" android:gravity="center"/>
Here the image width of the icon exceeds the screen.
I tried android:width="100dp" and all. But it isn't working.
Complete XML file:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle"> <stroke android:width="3dp" android:color="@color/black" /> <solid android:color="@color/bg_green" /> </shape> </item> <item> <bitmap android:src="@drawable/Icon" android:gravity="center"/> </item> </layer-list>
How can I reduce the width and height of the above bitmap?
Bitmap bm=((BitmapDrawable)imageView. getDrawable()). getBitmap(); Try having the image in all drawable qualities folders (drawable-hdpi/drawable-ldpi etc.)
A bitmap is simply a rectangle of pixels. Each pixel can be set to a given color but exactly what color depends on the type of the pixel. The first two parameters give the width and the height in pixels. The third parameter specifies the type of pixel you want to use.
Only API 23 or later
Just use
<item android:width="200dp" android:height="200dp" android:drawable="@drawable/splash_background" android:gravity="center" />
instead
<item android:left="200dp" android:right="200dp"> <bitmap android:src="@drawable/splash_background" android:gravity="center" /> </item>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With