Android中自定义漂亮动态样式
Android中自定义漂亮动态样式下面给大家演示制作工款精美的控件样式,可以应用到多种控件上。
1、在res中新建个drawable文件夹,然后在这文件夹上右击选择“新建”-“其它”-“Android Xml File”-“下一步”-输入文件名“my_style”,然后在下面选择“selector”。然后打开这个Xml文件,里面添加为如下:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape> <corners android:radius="10px"/> <gradient android:startColor="#f00" android:centerColor="#0f0" android:endColor="#00f"></gradient> <stroke android:width="2px" android:color="#ff0"></stroke> </shape> </item> <item android:state_active="true"> <shape> <corners android:radius="5px"/> <gradient android:startColor="#000" android:centerColor="#0f0" android:endColor="#fff"></gradient> <stroke android:width="2px" android:color="#f0f"></stroke> </shape> </item> </selector>
页:
[1]