Activity页面之间动画切换之淡入淡出
1 2 3
| Intent intent = new Intent(MainActivity2.this, MainActivity.class); startActivity(intent); overridePendingTransition(R.anim.fade_out,R.anim.fade_in);
|
在res中创建文件夹anim并在下面创建 fade_in.xml 和 fade_out.xml 两个文件
1 2 3 4 5 6 7 8 9
| <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <alpha android:duration="1000" android:fromAlpha="1.0" android:toAlpha="0.0" /> <!--duration:动画持续的时间;fromAlpha:开始时的透明度;toAlpha:结束时的透明度; --> </set>
|
1 2 3 4 5 6 7
| <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <alpha android:duration="1000" android:fromAlpha="0.0" android:toAlpha="1.0" /> </set>
|