如何动画骰子在 Kotlin 中吐出?

时间:2021-04-21 13:02:43

标签: android kotlin animation dice

我正在制作一个骰子应用程序。 当按钮被点击时,骰子会有动画,然后显示一个随机数。 到目前为止,我只成功地进行了旋转。 如何通过旋转进行编辑以抬起然后放下?

rotate.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <rotate xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="600"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:startOffset="0"
        android:toDegrees="720" />
</set>

MainActivity

val rotate = AnimationUtils.loadAnimation(this, R.anim.rotate)
            diceImage.startAnimation(rotate)

0 个答案:

没有答案