[Android] mobile guard input box jitter and mobile phone vibration
Check apidemos, find view / animation / shake, find the corresponding animation code, and copy it directly
When importing a project, it is reported that 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);
The XML file for animation is shake.xml
android:interpolator="@anim/cycle_7"
Interpolator is an inserter, which can define the speed of animation, etc
Call the setinterpolator () method of the animation object to set the inserter. Parameters: interpolator object
Implement the interpolator interface anonymously, override the getinterpolation () method, set the custom animation rate in, and pass in a flaot X
Vibration effect of input box
Get the vibrator object, call getsystemservice () method, parameter: vibrator_ SERVICE
Call the vibrate() method of the vibrator object, parameter: ms
The permission android.permission.vibrate needs to be added
This can make some vibrators~
shake.xml
cycle_ 7.xml