安卓属性动画设置无限循环播放

完整代码

    private fun rotate(srcView: View) {
        val animateTime = 5000L
        val animation = RotateAnimation(0f, 360f,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f)
        animation.fillAfter = true
        //设置无线循环
        animation.repeatCount = Animation.INFINITE
        //设置匀速旋转
        animation.interpolator = LinearInterpolator()
        animation.duration = animateTime
        srcView.startAnimation(animation)
    }

关键代码

        //设置无线循环
        animation.repeatCount = Animation.INFINITE
        //设置匀速旋转
        animation.interpolator = LinearInterpolator()

关注头条号,第一时间获取最新文章:

你可能感兴趣的:(安卓)