标签:
overridePendingTransition(enterAnim, exitAnim);
Intent intent =new Intent(this,item2.class);
startActivity(intent);
this.finish();
overridePendingTransition(android.R.anim.slide_in_left,android.R.anim.slide_out_right);
要整个应用改切换方式的话,那就用style控制吧
1、在res文件夹创建anim文件夹
2、添加以下文件:
slide_left_in.xml 从左边进来
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="200"
android:fromXDelta="-100.0%p"
android:toXDelta="0.0" />
</set>
slide_left_out.xml 从左边出去
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="200"
android:fromXDelta="0.0"
android:toXDelta="-100.0%p" />
</set>
slide_right_in.xml 从右边进来
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="200"
android:fromXDelta="100.0%p"
android:toXDelta="0.0" />
</set>
slide_right_out.xml 从右边出去
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="200"
android:fromXDelta="0.0"
android:toXDelta="100.0%p" />
</set>
属性讲解:
translate 位置转移动画效果
android:fromXDelta="0" -----------从0坐标开始开始
android:toXDelta="-100%p" ------移动距离到父层的-100%
两个参数都是指控件相对于parent的偏移距离
android:duration="200" -----------持续时间
3、修改主题样式
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:windowAnimationStyle">@style/activityAnimation</item>
</style>
<style name="activityAnimation" parent="@android:style/Animation">
<item name="android:activityOpenEnterAnimation">@anim/slide_right_in</item>
<item name="android:activityOpenExitAnimation">@anim/slide_left_out</item>
<item name="android:activityCloseEnterAnimation">@anim/slide_left_in</item>
<item name="android:activityCloseExitAnimation">@anim/slide_right_out</item>
</style>
以上内容转载自:
http://www.cnblogs.com/tinyphp/p/3926867.html
标签:
原文地址:http://www.cnblogs.com/chq3272991/p/5569823.html