Give the button a shake effect, you can do this, set up the Anim folder under Res, create a Button_shake.xml
<?xml version= "1.0" encoding= "Utf-8"? ><rotate xmlns:android= "Http://schemas.android.com/apk/res/android" android:duration= "android:fromdegrees=" -3 " android:pivotx=" 100% " android:pivoty=" 100% " android:repeatcount= "Infinite" android:repeatmode= "reverse" android:todegrees= "3"/>
In the code add:
Final ImageButton button = (ImageButton) Findviewbyid (R.ID.BTN); Button.setonclicklistener (new View.onclicklistener () {@Overridepublic void OnClick (View v) {Animation shake = Animationutils.loadanimation (Animationtest.this, R.anim.button_shake); Shake.reset (); Shake.setfillafter (true); Button.startanimation (shake);});
Give the edittext a lateral jitter effect:
Write Anim files like this:
<?xml version= "1.0" encoding= "Utf-8"? ><translate xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:fromxdelta=" 0 "android:toxdelta=" android:duration= "1300" android:interpolator= "@anim/cycle"/ >
Cycle.xml mainly describes the animation accelerator:
<?xml version= "1.0" encoding= "Utf-8"?><!--animation from start to finish, the rate of change is the sine curve of a given number of cycles. --><cycleinterpolator xmlns:android= "http://schemas.android.com/apk/res/android" android:cycles= "/>"
The code can be loaded like this:
Final Button confirm = (Button) Findviewbyid (r.id.btn_confirm); Confirm.setonclicklistener (new View.onclicklistener () {@Overridepublic void OnClick (View v) {if (Custom_edittext.gettext (). toString (). Equals ("Jake")) {Toast.maketext ( Animationtest.this, "Welcome", Toast.length_long). Show (); Else{animation shake = Animationutils.loadanimation (Animationtest.this, r.anim.shake_x); custom_ Edittext.startanimation (shake);}});
Code can be downloaded in http://download.csdn.net/detail/baidu_nod/7616277