Rotate 旋转loading实现对比

来源:互联网 发布:java在线视频网站源码 编辑:程序博客网 时间:2024/06/06 01:41
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"    android:repeatMode="restart">    <rotate        android:duration="600"        android:fromDegrees="0"        android:repeatCount="-1"        android:interpolator="@android:anim/accelerate_decelerate_interpolator"        android:pivotX="50%"        android:pivotY="50%"        android:toDegrees="360"/></set>

以上实现在动画结束到重新开始之间能明显感觉到停顿下的效果,因此用以下方式代替,RotateAnimation虽然api 11才 引入,但是测过在sdk 11的机器上任然有效

public static void startAnimaltion(View loadingAnimation) {        Animation mAnimation = new RotateAnimation(0, 359, Animation.RELATIVE_TO_SELF,    0.5f, Animation.RELATIVE_TO_SELF, 0.5f);        LinearInterpolator lin = new LinearInterpolator();        mAnimation.setRepeatCount(-1);        mAnimation.setInterpolator(lin);        mAnimation.setDuration(1000);        mAnimation.setFillAfter(true);        loadingAnimation.startAnimation(mAnimation);    }
0 0
原创粉丝点击