1、Shape的常用属性:
<shape> <!-- 实心 --> <solid android:color="#ff9d77"/> <!-- 渐变 --> <gradient android:startColor="#ff8c00" android:endColor="#FFFFFF" android:angle="270" /> <!-- 描边 --> <stroke android:width="2dp" android:color="#dcdcdc" /> <!-- 圆角 --> <corners android:radius="2dp" /> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> </shape>
2、一个按钮选择器示例:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" > <shape> <!-- 渐变 --> <gradient android:startColor="#ff8c00" android:endColor="#FFFFFF" android:type="radial" android:gradientRadius="50" /> <!-- 描边 --> <stroke android:width="2dp" android:color="#dcdcdc" android:dashWidth="5dp" android:dashGap="3dp" /> <!-- 圆角 --> <corners android:radius="2dp" /> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> </shape> </item> <item android:state_focused="true" > <shape> <gradient android:startColor="#ffc2b7" android:endColor="#ffc2b7" android:angle="270" /> <stroke android:width="2dp" android:color="#dcdcdc" /> <corners android:radius="2dp" /> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> </shape> </item> <item> <shape> <solid android:color="#ff9d77"/> <stroke android:width="2dp" android:color="#fad3cf" /> <corners android:topRightRadius="5dp" android:bottomLeftRadius="5dp" android:topLeftRadius="0dp" android:bottomRightRadius="0dp" /> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> </shape> </item> </selector>
参考:http://developer.android.com/guide/topics/resources/drawable-resource.html
相关推荐
Android shape的使用demo,非常简单,适合新手;是这篇博客(http://blog.csdn.net/u024496289/article/details/41924425)的demo代码
主要介绍了android shape的使用及渐变色、分割线、边框、半透明阴影,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
Android中使用Shape自定义形状
android shape的使用
android 用shape画出来的颜色做背景时,动态的改变它的颜色属性。
android-shape-imageview - 图片圆角、三角、五角、圆形、多角
android shape可以帮助我们实现很多的效果,比如:圆角、虚线边框、部分圆角、颜色的渐变等效果,同时源文件给出了android4.0系统下虚线会变成实线的解决办法。
Android shape属性详解
android 代码实现shape GradientDrawable
Android控件美化之Shape的使用 里面事例非常好的。
Android-shape标签的使用,让我们的界面更加高大上档次
android中shape的使用: http://blog.csdn.net/luohai859/article/details/41038443
Android shape 属性深入用法 我的博客:http://blog.csdn.net/xiaoyuan511
Android Shape源码实例,通过shape可以为为视图设置圆角背景,既可以通过在xml文件中直接为视图设置背景,又可以通过在代码中动态设置。
利用shape优化android UI
Android中shape的使用,细致讲解shape xml的使用规则,已经案例
Android:shape的使用详解(2)http://blog.csdn.net/wangyanguiyiyang/article/details/50060829
探索Android中selector和shape的结合使用
Android 绘制图形可以使用shape也可以使用自定义控件的方式,这里我们说下shape的方式去实现。 在绘制图形之前,我们先来了解下shape的几个属性。 shape /* * 线行 圆形 矩形 / android:shape=line android:shape...