ShapeDrawable

如何创建Drawable下的文件

用来定义 形状的 Drawable,根节点 shape,子节点比较多
属性

shape 下的属性

  • android:shape:rectangle(矩形) ,ring (圆),line (线),oval (椭圆)
  • visible:设置是否可见 感觉没效果
  • android:innerRadius 内圆半径
  • innerRadiusRatio 内圆半径比率
  • thickness 当shape为ring才有效,表示环的厚度,即外半径与内半径的差
  • thicknessRatio 当shape为ring才有效,表示环的厚度,即外半径与内半径的差
  • useLevel:当shape为ring才有效,表示是否允许根据level来显示环的一部分,设置为false

solid 填充色

  • android:color="@color/color06"

stroke 边框

  • width 边框宽度
  • color 边框颜色
  • dashWidth 虚线 显示部分宽度
  • dashGap 虚线缺口的宽度

corners 圆角

  • radius 圆角半径,四个角一致
  • topLeftRadius 左上角半径
  • topRightRadius 右上角半径
  • bottomLeftRadius 左下角半径
  • bottomRightRadius 右下角半径

size 大小

  • width 宽
  • height 高

padding

  • left,top,right,bottm:依次是左上右下方向上的边距!

gradient 渐变色

  • startColor 开始颜色
  • endColor结束颜色
  • centerColor中间色
    • angle:只有linear类型的渐变才有效,表示渐变角度,必须为45的倍数哦
    • type:渐变类型,可选(linear,radial,sweep), 线性渐变(可设置渐变角度),发散渐变(中间向四周发散),平铺渐变
  • centerX:渐变中间亚瑟的x坐标,取值范围为:0~1
  • centerY:渐变中间颜色的Y坐标,取值范围为:0~1
  • gradientRadius:只有radial和sweep类型的渐变才有效,radial必须设置,表示渐变效果的半径
  • useLevel:判断是否根据level绘制渐变效果

rectangle 矩形

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    >
    <corners android:radius="50dp"/>
    <solid android:color="@color/color06"/>
</shape>

ring 环

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"  //环,画圆还是用oval 吧
    android:useLevel="false"//这个必须设置false
    android:innerRadius="350px"//内环半径
    android:thickness="5dp"//圆环边框宽度
    >
    <solid android:color="@color/color02"/>  设置环的填充色
    
    渐变色的环,从左到右
    <gradient
        android:startColor="#ffffff"
        android:endColor="#000000"
        />

   

</shape>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值