效果: 一直不停的顺时针旋转

废话不多说, 上图:

效果: 一直不停的顺时针旋转.gif
    动画xml文件

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <!--
            效果: 一直不停的顺时针旋转
            android:toDegrees="359"         0~359防止卡顿
            android:pivotX="50%"            设置旋转中心点为控件中心
            android:repeatCount="-1"        设置不断旋转
        -->
        <rotate
            android:duration="1000"
            android:fromDegrees="0"
            android:pivotX="50%"
            android:pivotY="50%"
            android:repeatCount="-1"
            android:toDegrees="359" />
    </set>


    java代码: 给imageView设置动画

    Animation circle_anim = AnimationUtils.loadAnimation(AnimACT.this, R.anim.anim_round_rotate);
    //设置匀速旋转,在xml文件中设置会出现卡顿
    LinearInterpolator interpolator = new LinearInterpolator();
    circle_anim.setInterpolator(interpolator);
    if (circle_anim != null) {
        //开始动画
        ivIcon.startAnimation(circle_anim);
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容