SoFunction
Updated on 2025-04-03

A brief analysis of the jitter input box and mobile phone vibration of Android mobile phone guard

Check apiDemos, find View/Animation/shake to find the corresponding animation code, and copy it directly

When importing a project, the R file does not exist. In many cases, the xml file error occurred.

Animation shake = (this, );

et_phone.startAnimation(shake);

Animated xml file

android:interpolator="@anim/cycle_7"

Interpolator is an inserter that can define the speed of animations, etc.

Call the setInterpolator() method of the Animation object, set the inserter, parameters: Interpolator object

Implement the Interpolator interface anonymously, override the getInterpolation() method, set the custom animation rate, and pass in a flat 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

This can make some vibrators~

/**
 * Query the place of origin
 */
public void queryNumber(View v) {
phone = et_phone.getText().toString().trim();
if ((phone)) {
//Double animationAnimation shake = (this, );
et_phone.startAnimation(shake);
//The phone vibrates(2000);
(this, "Please enter your mobile phone number", 0).show();
return;
}
String result = (phone);
tv_address.setText(result);
}


<translate xmlns:andro
android:duration="1000"
android:fromXDelta="0"
android:interpolator="@anim/cycle_7"
android:toXDelta="10" /> 

cycle_7.xml

<cycleInterpolator xmlns:andro android:cycles="7" />

The above is the relevant content about the Android phone guard’s input box jitter and mobile phone vibration that the editor introduced to you. I hope it will be helpful to everyone!