Resize bitmap inside selected list layer 2

How to scale a bitmap like android: scaleType = "fitCenter"?

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@drawable/gradient"/>
    <item android:bottom="60dip">
        <bitmap
                android:gravity="center_horizontal|bottom"
                android:src="@drawable/image"/>
    </item>
</layer-list>

      

I have a 680x120px image and the image doesn't fit on the small screen. I experimented with gravity, but it didn't work for me (for example, I saw a 240x120 image but not a 240x42 image). I am using this style for the background of an activity and I cannot use ImageView.

+3


source to share


2 answers


If you are not using <LinearLayout> try using it with your approach.



0


source


Same problem here, but I solve this horizontal gravity fill problem and the second most important thing is you need to use a square image / PNG like 240p X 240p then the image will automatically resize to its screen.

<item
    android:drawable="@drawable/back">

</item>

<item>
        <bitmap
            android:gravity="fill_horizontal"

            android:tileMode="disabled"
            android:src="@drawable/logo"/>

</item>

      



0


source







All Articles