user5636914
user5636914

Reputation:

It is possible to set scaleType for item in layer-list like for imageView?

Look at the screenshot

enter image description here

Above I have the button with layer-list:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/button_yellow"/>
    <item
        android:top="5dp"
        android:bottom="5dp"
        android:left="5dp"
        >
        <bitmap android:src="@drawable/Export_hell_seidel_steiner"
            android:gravity="center"/>
    </item>
</layer-list>

<Button
        android:layout_width="341dp"
        android:layout_height="143dp"
        android:layout_margin="3dp"
        android:background="@drawable/layer1"
        android:onClick="onClick"
        android:text="" />

And below I have ImageButton

<ImageButton
    android:layout_width="299dp"
    android:layout_height="129dp"
    android:background="@drawable/button_yellow"
    android:padding="5dp"
    android:scaleType="fitCenter"
    android:src="@drawable/Export_hell_seidel_steiner"
    />

It is possible achieve similar result for layer-list? Should I create my custom BitmapDrawable class? I need scaleType = "fitCenter" in my item inside layer-list.

Upvotes: 2

Views: 695

Answers (1)

Gev
Gev

Reputation: 882

Unfortunately, you can't. Try to change the scale of the image

Upvotes: 1

Related Questions