shape文件放在哪里 android,Android Shape 资源文件

通过Shape实现圆环的绘制,遇到几个问题,刚开始一直绘制不出来,总结一下。

官方文档如下解释android:shape="ring"特有属性

android:innerRadius

Dimension. The radius for the inner part of the ring (the hole in the middle), as a dimension value or dimension resource.

android:innerRadiusRatioFloat. The radius for the inner part of the ring, expressed as a ratio of the ring's width. For instance, ifandroid:innerRadiusRatio="5", then the inner radius equals the ring's width divided by 5. This value is overridden byandroid:innerRadius. Default value is 9.android:thicknessDimension. The thickness of the ring, as a dimension value or dimension resource.android:thicknessRatioFloat. The thickness of the ring, expressed as a ratio of the ring's width. For instance, if android:thicknessRatio="2", then the thickness equals the ring's width divided by 2. This value is overridden by android:innerRadius. Default value is 3.android:useLevelBoolean. "true" if this is used as a

1. uselevel 属性默认是true,值为true意味着这是一个levelListDrawable

一个LeveListDrawable管理着一组交替的drawable资源。LeveListDrawable里面的每一个drawable资源与一个最大数值结合起来,作为LevelListDrawable资源的一项。调用Drawable的setLevel()方法可以加载level-list或代码中定义的某个drawable资源,判断加载某项的方式:level-list中某项的android:maxLevel数值大于或者等于setLevel设置的数值,就会被加载。

这里必须设置为false才会显示。

2.当用户设置android:innerRadius这个属性后,android:innerRadiusRatio 将会被覆盖,android:thicknessRatio同理!

如果不设置android:innerRadius,而设置android:innerRadiusRatio的话,默认值为9,假如设置为5的意思是,内圆环的半径为圆环宽度除以5得到的值。假如该值等于2的话,内圆就将占满整个shape,从而我们将看不到圆环。

3.Stroke标签可设置虚线效果

android:dashWidth——设置虚线效果里实点的长度

android:dashGap——设置虚线效果里空白点的长度

举个例子

android:innerRadius="80dp"

android:shape="ring"

android:thickness="50dp"

android:thicknessRatio="5"

android:useLevel="false">

android:width="400dp"

android:height="400dp" />

android:width="2dp"

android:color="#dcdcdc" />

效果如下 studio显示不知道为啥会多一条横线,实际是没有的。

0818b9ca8b590ca3270a3433284dd417.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值