Update Attributes during Rotation Animation

前端 未结 1 1131
轻奢々
轻奢々 2021-01-28 12:21

I\'m working on a rotation animation in Kotlin and I after each Animation I want to set a net rotationStart and rotationEnd where the rotationStart value initially should be set

1条回答
  •  隐瞒了意图╮
    2021-01-28 13:02

    Well, the only way I found until now is this here (just in case nobody will answer to this thread, here is my solution)

        val angles = arrayOf(9,6,9,4)
    
        var rotStart = 0f
        var imageSpinner = findViewById(R.id.img_spinner)
    
            val ra1 = RotateAnimation(rotStart,-angles[0].toFloat() * 39, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f)
        ra1.duration = 3200
    
        val ra2 = RotateAnimation(rotStart, -angles[1].toFloat() * 39, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f)
        ra2.duration = 1900
           val ra3 = RotateAnimation(rotStart, -angles[2].toFloat() * 39, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f)
        ra3.duration = 5400
        val ra4 = RotateAnimation(rotStart, -angles[3].toFloat() * 39, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f)
        ra4.duration = 5400
    

    after this you have to set on each onAnimationEnd: imageview.startAnimation(ra#NUMBER#). It's a workaround and not a clean solution :-)

    0 讨论(0)
提交回复
热议问题