Android Shape 资源文件
2016-10-09 18:46
441 查看
通过Shape实现圆环的绘制,遇到几个问题,刚开始一直绘制不出来,总结一下。
官方文档如下解释android:shape="ring"特有属性android:innerRadiusDimension. The radius for the inner part of the ring (the hole in the middle), as a dimension value or dimensionresource.
android:innerRadiusRatioFloat. The radius for the inner part of the ring, expressed as a ratio of the ring's width. For instance, if
android:innerRadiusRatio="5", then the inner radius equals the ring's widthdivided by 5. This value is overridden by
android:innerRadius. Default value is 9.
android:thicknessDimension. The thickness of the ring, as a dimension value or dimensionresource.
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. Thisvalue is overridden by
android:innerRadius. Default value is 3.
android:useLevelBoolean. "true" if this is used as a
LevelListDrawable.This should normally be "false" or your shape may not appear.
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——设置虚线效果里空白点的长度举个例子
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"android:innerRadius="80dp"android:shape="ring"android:thickness="50dp"android:thicknessRatio="5"android:useLevel="false"><sizeandroid:width="400dp"android:height="400dp" /><strokeandroid:width="2dp"android:color="#dcdcdc" /><solid android:color="#f2354e" /></shape>效果如下 studio显示不知道为啥会多一条横线,实际是没有的。
相关文章推荐
- android shape类型资源文件
- Android资源文件-Shape
- Android Shape资源文件gradient颜色渐变方向
- Android-关于资源文件shape的详解
- Android中String资源文件的format方法
- Android资源文件
- Android资源文件[转]
- Android对应用程序的资源文件xml解析的源代码在哪里
- 深入Android【七】 —— 资源文件 推荐
- android资源文件找不到
- Android资源文件
- 深入Android【七】 —— 资源文件
- android私有文件资源文件的存取
- 深入Android【七】—— 资源文件
- Android 读RAW下的资源文件
- Android工程内嵌资源文件的两种方法
- android通过拼写字符串获取资源文件
- 深入Android【七】 —— 资源文件
- 深入Android【七】 —— 资源文件
- android工程下的文件资源类型(转载)