我正在尝试使用图层列表在 XML 中定义自定义按钮形状,以避免向项目添加更多位图。我有这个:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
>
<item android:id="@+id/tester"
>
<rotate
android:pivotX="20%"
android:fromDegrees="-45"
>
<shape
android:shape="rectangle">
<solid
android:color="#000000"
>
</solid>
<size
android:height="200dp"
android:width="200dp"
>
</size>
</shape>
</rotate>
</item>
<item android:id="@+id/tester"
>
<rotate
android:pivotX="20%"
android:fromDegrees="45"
>
<shape
android:shape="rectangle">
<solid
android:color="#000000"
>
</solid>
<size
android:height="200dp"
android:width="200dp"
>
</size>
</shape>
</rotate>
</item>
<item>
<rotate
android:pivotX="90%"
android:fromDegrees="270"
>
<shape
android:shape="rectangle"
>
<solid
android:color="#000000"
>
</solid>
<size
android:width="50dp"
android:height="100dp"
>
</size>
</shape>
</rotate>
<item>
<rotate
android:pivotX="90%"
android:fromDegrees="90"
>
<shape
android:shape="rectangle"
>
<solid
android:color="#000000"
>
</solid>
<size
android:width="50dp"
android:height="100dp"
>
</size>
</shape>
</rotate>
</item>
我正在使用它来将其设置为一个按钮:
<Button
android:layout_width="15dp"
android:layout_height="fill_parent"
android:id="@+id/picture_inflator"
android:layout_toLeftOf="@id/picture_fragment"
android:layout_above="@+id/button"
android:layout_below="@+id/title"
android:background="@drawable/rightButton"
android:layout_marginLeft="4dp"
/>
我不知道这里发生了什么。我绘制了图像,想知道它是否包括超出边界的形状部分,但它看起来不像那样。在我知道它为什么会这样之前,我无法解决这个问题。我将不胜感激任何见解或猜测。谢谢
编辑:我知道我应该在这里使用选择器,但我现在只是在测试它。真正完成后,图像不会是哑光黑色。