设为首页 加入收藏

TOP

Android shap 控件美化
2015-02-02 14:31:57 来源: 作者: 【 】 浏览:13
Tags:Android shap 控件 美化

shap在drawable目录下,根节点为shap。


1.圆形或者椭圆形


android:shape="oval"? 椭圆


solid 颜色


控件长宽相等时显示圆,不相等时椭圆



? ? android:shape="oval" >? ?


? ?



使用时与drawable下的资源方式相同


? ? ? ? android:id="@+id/textview1"
? ? ? ? android:layout_width="30dp"
? ? ? ? android:layout_height="30dp"
? ? ? ? android:background="@drawable/textview_bg" />



2.圆角矩形
android:shape="rectangle" 矩形


corners 半径,可以分别对四个角设半径


? ? android:shape="rectangle" >


? ? ? ? ? ? android:bottomLeftRadius="10dip"
? ? ? ? android:bottomRightRadius="10dip"
? ? ? ? android:topLeftRadius="10dip"
? ? ? ? android:topRightRadius="10dip" />


? ?




3.渐变


gradient渐变


startColor 起始颜色


endColor 结束颜色


angle 渐变角度


padding 与控件边缘的距离



? ? android:shape="rectangle">
? ? ? ? ? ? android:startColor="#FFFF0000"
? ? ? ? android:endColor="#80FF00FF"
? ? ? ? android:angle="45"/>
? ? ? ? ? ? android:top="7dp"
? ? ? ? android:right="7dp"
? ? ? ? android:bottom="7dp" />
? ?




4.边框效果


stroke 边框,可以设置颜色和宽度



? ? android:shape="rectangle" >


? ? ? ? ? ? android:bottomLeftRadius="10dip"
? ? ? ? android:bottomRightRadius="10dip"
? ? ? ? android:topLeftRadius="10dip"
? ? ? ? android:topRightRadius="10dip" />


? ?


? ? ? ? ? ? android:color="@android:color/white"/>



5.圆环效果


就是shape="oval" 椭圆? 加上? stroke边框



? ? android:shape="oval" >


? ? ? ? ? ? android:bottomLeftRadius="10dip"
? ? ? ? android:bottomRightRadius="10dip"
? ? ? ? android:topLeftRadius="10dip"
? ? ? ? android:topRightRadius="10dip" />


? ?


? ? ? ? ? ? android:color="@android:color/white"/>



】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android ContentObserver使用实现.. 下一篇Android 手电筒(最强适配版)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: