自定义圆形进度条

来源:互联网 发布:杭州 大学生家教 知乎 编辑:程序博客网 时间:2024/05/16 17:52

rotate

fromDegrees   动画开始时的角度   toDegrees     动画结束时物件的旋转角度,正代表顺时针     pivotX    属性为动画相对于物件的X坐标的开始位置  pivotY    属性为动画相对于物件的Y坐标的开始位置duration 设置时间

Shape

android:shape=["rectangle" | "oval" | "line" | "ring"]   shape的形状,默认为矩形,可以设置为矩形(rectangle)、椭圆形(oval)、线性形状(line)、环形(ring)   下面的属性只有在android:shape="ring时可用:   android:innerRadius         尺寸,内环的半径。   android:innerRadiusRatio    浮点型,以环的宽度比率来表示内环的半径,   android:thickness           尺寸,环的厚度   android:thicknessRatio      浮点型,以环的宽度比率来表示环的厚度,例如,如果android:thicknessRatio="2",   android:useLevel      boolean值,如果当做是LevelListDrawable使用时值为true,否则为false. 

gradient

<gradient      android:type=["linear" | "radial" | "sweep"]    //共有3中渐变类型,线性渐变(默认)/放射渐变/扫描式渐变       android:angle="integer"     //渐变角度,必须为45的倍数,0为从左到右,90为从上到下       android:centerX="float"     //渐变中心X的相当位置,范围为0~1       android:centerY="float"     //渐变中心Y的相当位置,范围为0~1       android:startColor="color"   //渐变开始点的颜色       android:centerColor="color"  //渐变中间点的颜色,在开始与结束点之间       android:endColor="color"    //渐变结束点的颜色       android:gradientRadius="float"  //渐变的半径,只有当渐变类型为radial时才能使用       android:useLevel=["true" | "false"] />  //使用LevelListDrawable时就要设置为true。设为false时才有渐变效果  

实现

<?xml version="1.0" encoding="utf-8"?><rotate xmlns:android="http://schemas.android.com/apk/res/android"    android:pivotX="50%" android:pivotY="50%" android:toDegrees="360">    <!--innerRadiusRatio 内环半径  thicknessRatio环的厚度 sweep扫描式渐变-->    <shape android:shape="ring"        android:innerRadiusRatio="3"        android:thicknessRatio="8"        android:useLevel="false">        <gradient android:useLevel="false"            android:centerColor="#E8ECBB"            android:endColor="#479FD9"            android:startColor="#8ED2CD"            android:centerY="0.5"            android:centerX="0.5"            android:type="sweep"></gradient>    </shape></rotate>

这里写图片描述