To achieve the vibration effect of the view, you only need to add animation to the required view. Proceed as follows:
Create anim folder under res. and create two files. as follows:
shake.xml:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="600"
android:fromXDelta="0"
android:toXDelta="10"
android:interpolator="@anim/cycle_7"/>
cycle_7.xml:
<?xml version="1.0" encoding="utf-8"?>
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="7" />
Then it is used. in the desired position. Set the target view as follows:
val shake = AnimationUtils.loadAnimation(this, R.anim.shake);
tv.startAnimation(shake);
END