Android中自定义漂亮动态样式
<div id="cnblogs_post_body">Android中自定义漂亮动态样式下面给大家演示制作工款精美的控件样式,可以应用到多种控件上。
1、在res中新建个drawable文件夹,然后在这文件夹上右击选择&ldquo;新建&rdquo;-&ldquo;其它&rdquo;-&ldquo;Android Xml File&rdquo;-&ldquo;下一步&rdquo;-输入文件名&ldquo;my_style&rdquo;,然后在下面选择&ldquo;selector&rdquo;。然后打开这个Xml文件,里面添加为如下:
<div class="cnblogs_code"><?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]