友好的界面可以给用户留下深刻印象,为APP加分,今天实现的这个进度条,以蜗牛爬动的方式告诉用户当前进度,体验比较棒,这里分享一下。
这里创建一组帧动画作为进度条的标志,如下:
<?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/s1" android:duration="300" />
<item android:drawable="@drawable/s2" android:duration="300" />
<item android:drawable="@drawable/s3" android:duration="300" />
<item android:drawable="@drawable/s4" android:duration="300" />
<item android:drawable="@drawable/s5" android:duration="300" />
</animation-list>
设置了onshot属性值为false,保证动画可以一直循环。这里添加了5张图片,每隔300毫秒进行轮换,会形成一组流畅的动画。
自定义View继承自Seekbar,如下:
public class SnailBar extends SeekBar {
public SnailBar(Context context) {
super(context);
init();
}
public SnailBar(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public SnailBar(Context context,