Android开发仿抖音跑马灯和旋转头像效果
仿抖音跑马灯和旋转头像效果
一、思路:
用RotateAnimation和自定义MarqueeTextView
二、效果图:
三、关键代码:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val rlAnim = findViewById<View>(R.id.rlAnim)
setRotateAnim(rlAnim)
}
private fun setRotateAnim(view:View) {
val rotateAnimation = RotateAnimation(0f, 359f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f)
rotateAnimation.repeatCount = Animation.INFINITE
rotateAnimation.duration = 8000
四、项目demo源码结构图:
有问题或者需要完整源码demo的私信我,我每天都看私信的。