Android commonly used animation has animation, animator two kinds;
---The 1th common use is in activity switching. For example, open an activity. Close an activity a person prefers the effect of sliding left and right (as for how XML is configured tween animation is not in the repeat, the Internet is everywhere)
1. Activate activity
private void Gotoregistactivity () {Intent intent=new Intent (); Intent.setclass (Getactivity (), registactivity.class); StartActivity (intent); Getactivity (). Overridependingtransition (r.anim.slide_right_in,r.anim.slide_left_out);}
2. Close activity (here a personal project does an activity base class that implements code in the base class)
@Overridepublic boolean onKeyDown (int keyccode, keyevent keyevent) {if (keyccode==keyevent.keycode_back) {this.finish ( ); Overridependingtransition (r.anim.slide_left_in,r.anim.slide_right_out); return true;} Return Super.onkeydown (Keyccode, keyevent);}
---animator configuration
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" > <objectanimator android:interpolator= "@android: Interpolator/decelerate_quint" android: Valuefrom= "200DP" android:valueto= "0DP" android:valuetype= "Floattype" android:propertyname= " Translationx " android:duration=" "/> <objectanimator android:interpolator=" @android: Interpolator/decelerate_quint " android:valuefrom=" 0.0 "android:valueto=" 1.0 " android:valuetype=" Floattype " android:propertyname=" Alpha " android:duration="/></set>
2. General animator is configured on the new API, such as we are familiar with the fragment inside, the Internet to find a bit, said is Add,remove, before the call, tested, after the fragmenttransaction opened the transaction
Call: (The following code has an effect before calling detach (), slide's XML is based on a slight change above, and if the reader wants to see things time, suggest adding animation time observations):
Mtransaction.setcustomanimations (r.anim.slide_frag_in,r.anim.slide_frag_out);
Android-animation Advanced (Create user-friendly animations)