<?xml version="1.0" encoding="utf-8"?><cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="10" />
Down is the interaction between the left and the right: shake. xml
<?xml version="1.0" encoding="utf-8"?><translate xmlns:android="http://schemas.android.com/apk/res/android"android:fromXDelta="0" android:toXDelta="5" android:fromYDelta="5" android:toYDelta="0" android:duration="1000" android:interpolator="@anim/cycleinter" />
<?xml version="1.0" encoding="utf-8"?><translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1000" android:fromYDelta="0" android:interpolator="@anim/cycleinter" android:toYDelta="3" />
This basically completes the dynamic effect.
Directly in the Code:
Animation shakeAnimation = AnimationUtils.loadAnimation(this, R.anim.shake_xy);view.startAnimation(shakeAnimation);
Now, the mobile phone shake and QQ sound prompts are added to the shake effect:
SoundPool soundPoolsoundPool = new SoundPool (10, AudioManager. STREAM_SYSTEM, 5); // The maximum number of sounds that can be released at the same time, the number of two sound types, and the higher the sound quality, the more resource-consuming soundPool. load (this, R. raw. aa, 1); // context id level public void soundPlay () {// 1st parameter IDS (put first in the order of soundpool) // control volume of the left audio channel (2 and 3) and control volume of the right audio channel (/4 priority) // 5 whether to loop 0-not loop-1-loop/6 play ratio 0.5-2 generally 1 indicates normal play soundPool. play (1, 1, 1, 1, 0, 1);} public void zhendong () {// do not forget the vibration permission Vibrator vibrator = (Vibrator) this. getSystemService (VIBRATOR_SERVICE); long [] pattern = {50,400, 50,400}; // stop start to stop enabling vibrator. vibrate (pattern,-1); // you can set it to 1-1} if it is not repeated}