直接上代码!
1.res中rotate的xml文件
android:fromDegrees="0" android:pivotX="50%" android:pivotY="50%" android:toDegrees="1080.0"> <!--android:fromXScale 起始的X方向上相对自身的缩放比例,浮点值,比如1.0代表自身无变化,0.5代表起始时缩小一倍,2.0代表放大一倍;--> <!--android:toXScale 结尾的X方向上相对自身的缩放比例,浮点值;--> <!--android:fromYScale 起始的Y方向上相对自身的缩放比例,浮点值,--> <!--android:toYScale 结尾的Y方向上相对自身的缩放比例,浮点值;--> <!--android:pivotX 缩放起点X轴坐标,可以是数值、百分数、百分数p 三种样式,比如 50、50%、50%p,当为数值时,表示在当前View的左上角,即原点处加上50px,做为起始缩放点;如果是50%,表示在当前控件的左上角加上自己宽度的50%做为起始点;如果是50%p,那么就是表示在当前的左上角加上父控件宽度的50%做为起始点x轴坐标。(具体意义,后面会举例演示)--> <!--android:pivotY 缩放起点Y轴坐标,取值及意义跟android:pivotX一样。--> <shape android:innerRadiusRatio="3" android:shape="ring" android:thicknessRatio="9" android:useLevel="false"> <gradient android:endColor="#ff0" android:startColor="#0f0" android:type="linear" /> </shape>
2.style
<style name="ring"> <item name="android:layout_width">100dp</item> <item name="android:layout_height">100dp</item> <item name="android:indeterminateDrawable">@drawable/progressbar</item> </style>
3.使用
<ProgressBar style="@style/ring" android:id="@+id/progressBar" />
4.运行看效果就哦了