我尝试使用图层列表将可绘制位图居中在带有填充的形状中。但我无法在图像周围填充。这不起作用:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:angle="270"
android:centerColor="#ffffffff"
android:endColor="#ffbab8b9"
android:startColor="#ffcfccce" />
<stroke
android:width="1px"
android:color="#A0A0A0" />
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" />
</shape>
</item>
<item
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp">
<bitmap android:src="@drawable/logo"
android:gravity="center" />
</item>
</layer-list>
有人知道如何使用填充将位图(用于缩放)居中吗?
现在 bottom,left,... 参数只是被忽略了。位图在 Button 内缩放 100%。
我需要它作为 Button 并且不能在这里使用 ImageButton。此外 Button 在这种特殊情况下没有文本,因此 CompoundDrawable 也不起作用。我需要用一个按钮来做。
最好的问候,于尔根