Android实现扫描二维码动画效果

如图:

 

中心的线在从上到下的动画效果

代码实现:

 private fun initAnimation() {
        val mAnimation = TranslateAnimation(TranslateAnimation.ABSOLUTE, 0f, TranslateAnimation.ABSOLUTE,0f, TranslateAnimation.RELATIVE_TO_PARENT, 0f,
            TranslateAnimation.RELATIVE_TO_PARENT, 0.9f)
        mAnimation.duration = 1500
        mAnimation.repeatCount = -1
        mAnimation.repeatMode = Animation.RESTART
        mAnimation.interpolator = LinearInterpolator()
        binding.imgLine.animation = mAnimation

    }

  

 

 

完成

 

 

参考于:https://blog.csdn.net/lindonghai/article/details/80775775

 

posted on 2022-02-14 16:52  巫山老妖  阅读(1683)  评论(0编辑  收藏  举报