原理:
アニメーションで実現
1. res-anmiフォルダーの下に翻訳アニメーションファイルを作成します
2.AnimationUtils を使用してアニメーションをロードします
シェイク_チェックボックス.xml
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromXDelta="0"
android:interpolator="@anim/shake_interpolator"
android:toXDelta="30">
</translate>
内部の補間器:
シェイク_インターポレーター.xml
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
android:cycles="2"><!-- 抖动次数-->
</cycleInterpolator>
使用:
val loadAnimation = AnimationUtils.loadAnimation(this, R.anim.shake_checkbox)
login_agreement_rl.startAnimation(loadAnimation)
login_agreement_rl はシェイクするコントロールです