如下背景在按钮属性android:background="@drawable/"中添加: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 连框颜色值 --><item> <shape> <solid android:color="#151104" /> <corners android:radius="4dp" /> </shape> </item> <!-- 主体背景颜色值 --> <item android:bottom="1dp" android:right="1dp" android:top="1dp" android:left="1dp"> <shape> <!--android:centerColor="#ff3399"--> <gradient android:startColor="@color/paleBrown" android:endColor="@color/light_paleBrown" android:type="linear" android:angle="90" android:centerX="0.5" android:centerY="0.5" /> <padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp" /> <!-- 圆角 --> <corners android:radius="4dp" /> </shape> </item> </layer-list>
如下点击效果在按钮属性android:src="@drawable/"中添加:
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <shape android:shape="rectangle"> <solid android:color="#21000000" /> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="#00000000" /> </shape> </item> </selector>