Check Apidemos, find view/animation/shake to find the corresponding animation code, directly copied 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 a plug-in that can define the speed of the animation, etc.
Call the Setinterpolator () method of the Animation Object , set the caret, parameter:interpolator Object
Implement the interpolator interface anonymously, override the getinterpolation () method, set the custom animation rate, pass in a flaot x
Vibration Effect of input box
Get the vibrator object, call the getsystemservice () method, Parameter:vibrator_service
Call the vibrate () method of the Vibrator Object , parameter: milliseconds
Need to add permissions Android.permission.VIBRATE
This can do some vibrators ~
/** * Enquiry of place of Attribution*/ PublicvoidQuerynumber (View v) {phone=Et_phone.gettext (). toString (). Trim (); if(Textutils.isempty (phone)) {//jitter AnimationsAnimation shake = Animationutils.loadanimation ( This, R.anim.shake); Et_phone.startanimation (shake); //Mobile phone VibrationVibrator.vibrate (2000); Toast.maketext ( This, "Please enter your mobile number", 0). Show (); return; The String result=numberqueryaddressutil.queryaddress (phone); Tv_address.settext (result); }
Shake.xml
<xmlns:android= "http://schemas.android.com/apk/res/android" Android :d uration= " android:fromxdelta"= "0" Android:interpolator = "@anim/cycle_7" android:toxdelta= "Ten"/>
Cycle_7.xml
<xmlns:android= "http://schemas.android.com/apk/res/android" android: Cycles= "7"/>
[Android] Mobile defender input box jitter and phone shake