imageViewのBUZZのようなアニメーションを作成しました。ここでは、 Buzzy 効果のように遅延を追加しています。
- アクティビティで:
ここanimShake
は、android.view.animation
animShake = AnimationUtils.loadAnimation(this, R.anim.shake)
imageView.startAnimation(animShake)
AnimationListener
BUZZ効果の少しの遅延のために追加することを忘れないでください
animShake.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationRepeat(animation: Animation?) {
}
override fun onAnimationEnd(animation: Animation?) {
Handler().postDelayed({
imageView.startAnimation(animShake)
}, 1000)
}
override fun onAnimationStart(animation: Animation?) {
}
})
のみを持つアニメーションshake
XML ファイルtranslate
:
android:duration="75"
android:fromXDelta="-18%"
android:repeatCount="11"
android:repeatMode="reverse"
android:toXDelta="18%" />