Android uses the Animation to achieve the jitter of interface components. The following API Demos provided by the system:
Directory for android-sdksamplesandroid-8ApiDemos has achieved a simple jitter effect:
The specific usage is as follows:
Step 1: Prepare two XML files for the animation effect and add them to the res/anim/directory:
Shake. xml file:
<Translate xmlns: android = "http://schemas.android.com/apk/res/android"
Android: fromXDelta = "0"
Android: toXDelta = "10"
Android: duration= "1000"
Android: interpolator = "@ anim/cycle_7"/>
Cycle_7.xml file:
<CycleInterpolator xmlns: android = "http://schemas.android.com/apk/res/android"
Android: cycles = "7"/>
Step 2: // use the animation effect for the Code:
Animation shake = AnimationUtils. loadAnimation (this, R. anim. shake); // load the Animation resource file
FindViewById (R. id. xxxx). startAnimation (shake); // play the animation effect on the Component