Android -- 自定义ProgressBar图片
2019-07-09 本文已影响0人
学习_猫
注:所有的进度条都要配置
android:indeterminateDrawable="样式文件名称"
- 图片旋转
注意:android:drawable属性使用xml文件的图片资源类型,动画可能会有问题(如闪烁),尤其在高版本上,此时只能使用png等类型
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<rotate
android:drawable="@drawable/dialog_progress_round"
android:fromDegrees="0.0"
android:pivotX="50.0%"
android:pivotY="50.0%"
android:toDegrees="360.0" />
</item>
</layer-list>
或者
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/im_send_loading"
android:pivotX="50%"
android:pivotY="50%" />
2.帧动画效果
loading.png<?xml version="1.0" encoding="UTF-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<item
android:drawable="@drawable/loading_01"
android:duration="150"/>
<item
android:drawable="@drawable/loading_02"
android:duration="150"/>
<item
android:drawable="@drawable/loading_03"
android:duration="150"/>
<item
android:drawable="@drawable/loading_04"
android:duration="150"/>
<item
android:drawable="@drawable/loading_05"
android:duration="150"/>
<item
android:drawable="@drawable/loading_06"
android:duration="150"/>
<item
android:drawable="@drawable/loading_07"
android:duration="150"/>
</animation-list>
3.设置背景颜色
loading.png
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" >
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="8"
android:useLevel="false" >
<gradient
android:centerColor="#FFDC35"
android:centerY="0.50"
android:endColor="#CE0000"
android:startColor="#FFFFFF"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>