Switching animation activity
In the onCreate()
function of setContentView(R.layout.activity_main);
adding front getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
indicate that you want to apply the transitional animation activities
Then leave to add the following activities and events into the animation getWindow().setEnterTransition(TransitionInflater.from(this).inflateTransition(R.transition.explode));
andgetWindow().setExitTransition(TransitionInflater.from(this).inflateTransition(R.transition.fade));
Which R.xxxx
is a custom file, customize the way events
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.activity_main2);
getWindow().setEnterTransition(TransitionInflater.from(this).inflateTransition(R.transition.explode));
getWindow().setExitTransition(TransitionInflater.from(this).inflateTransition(R.transition.fade));
}
This makes it possible to switch between animation Activity
After res/transition
creating a file folder, here are some of my papers transition mode:
explode
<?xml version="1.0" encoding="utf-8"?>
<explode xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"/>
fade
<?xml version="1.0" encoding="utf-8"?>
<fade xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"/>
slide_bottom
<?xml version="1.0" encoding="utf-8"?>
<slide xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:slideEdge="bottom"/>
slide_left
<?xml version="1.0" encoding="utf-8"?>
<slide xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:slideEdge="start"/>
slide_right
<?xml version="1.0" encoding="utf-8"?>
<slide xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:slideEdge="end"/>
slide_top
<?xml version="1.0" encoding="utf-8"?>
<slide xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:interpolator="@android:interpolator/accelerate_cubic"
android:slideEdge="top" />