The implementation of QQ vibration windows is similar to that of android, with sound and vibration effects

Source: Internet
Author: User

<?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}







Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.