Android shape属性大全

  1. corners(圆角)
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
  <corners    //定义圆角   
    android:radius="10dp"  //全部的圆角半径;   
    android:topLeftRadius="5dp"  //左上角的圆角半径;   
    android:topRightRadius="5dp" //右上角的圆角半径;   
    android:bottomLeftRadius="5dp"  //左下角的圆角半径;   
    android:bottomRightRadius="5dp" /> //右下角的圆角半径。
</shape>  
  1. solid(填充色)
<shape xmlns:android="http://schemas.android.com/apk/res/android" > 
    <solid android:color="#ffff00"/> //内部填充色
</shape> 
  1. gradient(渐变)
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
  <gradient  
    android:type=["linear" | "radial" | "sweep"]   //共有3中渐变类型,线性渐变(默认)/放射渐变/扫描式渐变;
    android:angle="90"  //渐变角度,必须为45的倍数,0为从左到右,90为从上到下;   
    android:centerX="0.5"  //渐变中心X的相当位置,范围为0~1;
    android:centerY="0.5"  //渐变中心Y的相当位置,范围为0~1;   
    android:startColor="#24e9f2"  //渐变开始点的颜色;   
    android:centerColor="#2564ef" //渐变中间点的颜色,在开始与结束点之间;   
    android:endColor="#25f1ef"  //渐变结束点的颜色;   
    android:gradientRadius="5dp"  //渐变的半径,只有当渐变类型为radial时才能使用;   
    android:useLevel="false" /> //使用LevelListDrawable时就要设置为true。设为false时才有渐变效果。  
</shape> 
  1. stroke(描边)
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
  <stroke        
    android:width="1dp"   //描边的宽度   
    android:color="#ff0000"   //描边的颜色   
    // 以下两个属性设置虚线   
    android:dashWidth="1dp" //虚线的宽度,值为0时是实线   
    android:dashGap="1dp" />//虚线的间隔
</shape>

只想要一边的效果
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:left="-2dp"
        android:right="-2dp"
        android:bottom="-2dp">
        <shape>
            <stroke
                android:width="1dp"
                android:color="#80646F9A"/>
        </shape>
    </item>
</layer-list>
  1. padding(内边距)
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
  <padding    
    android:left="10dp"  //左内边距; 
    android:top="10dp"   //上内边距;
    android:right="10dp"   //右内边距;
    android:bottom="10dp" /> //下内边距。
</shape>  
  1. size(大小)
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
  <size   
    android:width="50dp"  //宽度 
    android:height="50dp" />// 高度
</shape> 
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值