Android-Animation (advanced tutorial for creating user-friendly animations) and androidanimation
Commonly used animations in android include Animation and Animator;
--- The 1st commonly used methods are used in Activity switching. for example, open an Activity. the effect of Sliding between the left and right is preferred for closing an Activity (as for how to configure the Tween animation in xml, it is everywhere on the Internet)
1. Start 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 the Activity (here, my project creates an Activity base class to implement 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="500" /> <objectAnimator android:interpolator="@android:interpolator/decelerate_quint" android:valueFrom="0.0" android:valueTo="1.0" android:valueType="floatType" android:propertyName="alpha" android:duration="500" /></set>
2. Generally, Animator is configured on a new API, such as the Fragment that we are familiar with. I searched for it online, saying "add" and "remove". It is called before. After testing, after the FragmentTransaction starts the transaction
Call: (the following code is effective before detach () is called. The slide xml can be slightly changed based on the above Code. If you want to view the time, you are advised to add the animation time observation ):
mTransaction.setCustomAnimations(R.anim.slide_frag_in,R.anim.slide_frag_out);
Android: animation Problems
You can use property animation to adjust translationX or translationY to move the file.
Android Animation
There is a method, but it is not a good dismissal plan. I tried. If setFillAfter (true) is not set, the control is moved to the animation end position in the animation end listener. However, it has a jitter Bug.