android中shape的使用

来源:互联网 发布:壁虎数据恢复免root版 编辑:程序博客网 时间:2024/06/06 11:02
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >


    <!-- 
    gradient渐变
    angle是渐变角度,必须为45的整数倍 -->
    <gradient
        android:angle="90"
        android:endColor="#000000"
        android:startColor="#000000" />
    <!-- 实心 -->
    <solid android:color="#ffffff" />
    <!--
corners:圆角
android:radius为角的弧度,值越大角越圆。
<corners  
                android:radius="2dp" />  
我们还可以把四个角设定成不同的角度,方法为:
<corners  
  
        android:topRightRadius="20dp"    右上角  
        android:bottomLeftRadius="20dp"    右下角  
        android:topLeftRadius="1dp"    左上角  
        android:bottomRightRadius="0dp"    左下角  
/>  
还有网上看到有人说设置成0dp无效,不过我在测试中发现是可以的,我用的是2.2,可能修复了这个问题吧,如果无效的话那就只能设成1dp了。




    -->


    <corners
        android:bottomLeftRadius="15px"
        android:bottomRightRadius="15px"
        android:topLeftRadius="15px"
        android:topRightRadius="15px" />
    <!-- 描边 -->
    <stroke
        android:width="2dp"
        android:color="#dcdcdc" />
    <!--
stroke:描边
android:width="2dp" 描边的宽度,android:color 描边的颜色。
我们还可以把描边弄成虚线的形式,设置方式为:
android:dashWidth="5dp"
android:dashGap="3dp"
其中android:dashWidth表示'-'这样一个横线的宽度,android:dashGap表示之间隔开的距离。




    -->


</shape>
0 0
原创粉丝点击