mfc*_*mfc 4 android android-custom-drawable
如何使用xml中定义的多个形状作为android中按钮的背景?
假设我有多个形状的xml文件,例如: -
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#eeffffff" />
<corners android:bottomRightRadius="8dip"
android:bottomLeftRadius="8dip"
android:topRightRadius="8dip"
android:topLeftRadius="8dip"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
我想在按钮背景中使用multishapes: -
<Button
android:id="@+id/funkyButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="@string/txt_higher"
android:background="@drawable/funkyShape"/>
Run Code Online (Sandbox Code Playgroud)
我如何组合多个形状最终得到一个像这样的按钮: - ?

尝试funkyShape.xml,如:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<size
android:width="100dp"
android:height="40dp" />
<solid android:color="#ff0000" />
<corners android:radius="30dp"/>
</shape>
</item>
<item
android:top="10dp"
android:left="10dp"
android:right="60dp"
android:bottom="10dp">
<rotate
android:fromDegrees="45"
android:toDegrees="45">
<shape android:shape="rectangle">
<solid android:color="#ffff00" />
<corners android:radius="5dp"/>
</shape>
</rotate>
</item>
<item
android:top="5dp"
android:left="55dp"
android:right="5dp"
android:bottom="5dp">
<shape android:shape="oval">
<solid android:color="#0000ff" />
</shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3303 次 |
| 最近记录: |