Analysis on the jitter input frame and mobile phone vibration _android of Android handset Guardian

Source: Internet
Author: User

See Apidemos, find View/animation/shake find the corresponding animation code, direct copy over

When importing a project, the R file does not exist, in many cases the XML file is wrong

Animation shake = Animationutils.loadanimation (this, r.anim.shake);

Et_phone.startanimation (shake);

Animated XML File Shake.xml

Android:interpolator= "@anim/cycle_7"

Interpolator is an INSERT, you can define the speed of the animation, etc.

Invokes the Setinterpolator () method of the animation object, setting the INSERT, Parameter: Interpolator object

Implement the Interpolator interface anonymously, rewrite the Getinterpolation () method, set the custom animation rate, and pass in a flaot x

The vibration effect of the input frame

Gets the vibrator object, calls the Getsystemservice () method, Parameters: Vibrator_service

Call the Vibrator object's vibrate () method, parameters: milliseconds

Need to add permissions Android.permission.VIBRATE

This can do some vibrator ~

/**
* Query Attribution/
public
void Querynumber (View v) {
phone = Et_phone.gettext (). toString (). Trim ();
if (Textutils.isempty (phone)) {
//dither animation
Animation shake = Animationutils.loadanimation (this, r.anim.shake);
Et_phone.startanimation (shake);
Mobile phone Vibration
vibrator.vibrate ();
Toast.maketext (This, "Please enter your mobile number", 0). Show ();
return;
}
String result = numberqueryaddressutil.queryaddress (phone);
Tv_address.settext (result);
}

Shake.xml

<translate xmlns:android= "http://schemas.android.com/apk/res/android"
android:duration= "1000"
Android:fromxdelta= "0"
android:interpolator= "@anim/cycle_7"

Cycle_7.xml

<cycleinterpolator xmlns:android= "Http://schemas.android.com/apk/res/android" android:cycles= "7"/>

The above is a small series to introduce the Android phone defender's input frame jitter and mobile phone vibration related content, I hope to help you!

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.