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

Android:改变Activity切换方式(转载)的更多相关文章

  1. [转]Android:改变Activity切换方式

    overridePendingTransition(enterAnim, exitAnim); Intent intent =new Intent(this,item2.class); startAc ...

  2. Android:改变Activity切换方式

    overridePendingTransition(enterAnim, exitAnim); Intent intent =new Intent(this,item2.class); startAc ...

  3. Android的Activity切换动画特效库SwitchLayout,视图切换动画库,媲美IOS

    由于看了IOS上面很多开发者开发的APP的视图界面切换动画体验非常好,这些都是IOS自带的,但是Android的Activity等视图切换动画并没有提供原生的,所以特此写了一个可以媲美IOS视图切换动 ...

  4. Android 启动Activity的方式

    Activity的启动分为两种方式,显示方式和隐式方式,显示方式就是在通过intent启动Activity时指定了Activity的包名和类名. 而隐式方式则在初始化Intent时仅仅指定action ...

  5. 更改activity切换方式

    overridePendingTransition(enterAnim, exitAnim); Intent intent =new Intent(this,item2.class); startAc ...

  6. Android 之Activity切换动画效果

    在Activity中Android提供了overridePendingTransition(int enterAnim,int exitAnim)这个方法用于设置Activity之间切换的动画效果.o ...

  7. android退出activity的方式总结(一)

    在android中使用:[activityname].this.finish();  只是退出了activity的堆栈中,要真正的退出程序在手机cpu中的运行,当应用不再使用时,通常需要关闭应用,可以 ...

  8. Android之Activity切换

    ●假如有Activity01和Activity02,从Activity01切换到Activity02并传递参数. Activity01中: button.setOnClickListener(new  ...

  9. Android中Activity切换时共享视图元素的切换动画(5.0以上)

    同一时候公布在我的博客 点此进入 背景 说来这个的背景很easy,常常在使用图片列表的时候就会想,假设"列表中的图片放大到整个屏幕"作为 Activity 的补间动画.就很完美了. ...

随机推荐

  1. iOS静态库.a文件制作和导入使用

    iOS静态库.a文件制作: 1.新建Cocoa Touch Static Library工程 新建工程 - 选择iOS-FrameWork&Libary,选择 Cocoa Touch Stat ...

  2. 在Spring项目中使用Log4j记录日志

    (1)引入log4j的jar包: 官网下载地址:http://logging.apache.org/log4j/1.2/download.html (2)在web.xml中添加log4j配置: 1 2 ...

  3. shell 小问题汇总

    写脚本的时候难免会判断变量是否为空或者为定义 变量a未定义 if [ -n $a ];then echo "exists"; else echo "not exists& ...

  4. SDAutoLayout:比masonry更简单易用的自动布局库

    SDAutoLayout:一行代码搞定自动布局!支持Cell和Tableview高度自适应,Label和ScrollView内容自适应,致力于做最简单易用的AutoLayout库. [SDAutoLa ...

  5. CSS3中:nth-child和:nth-of-type的区别深入理解

    关于:nth-child和:nth-of-type的区别之前一直没太注意.最近打算深入了解一些CSS3,才发现里面其实暗藏玄机. :nth-child可以选择父元素下的字元素,:nth-of-type ...

  6. 关于CSS3的代码总结(部分)

    1. 构造样式表:selector{ Property:value; Property:value; } Selector是需要更改样式的元素,property为css属性的名称,value应用的哪种 ...

  7. Programming Assignment 4: 8 Puzzle

    The Problem. 求解8数码问题.用最少的移动次数能使8数码还原. Best-first search.使用A*算法来解决,我们定义一个Seach Node,它是当前搜索局面的一种状态,记录了 ...

  8. modelbinder机制原理

    ModelBinder介绍 一.问题描述 当运行一个Mvc时,你控制器中的Action方法需要参数数据:而这些参数数据包含在HTTP请求中,包括表单上的Value和URL中的参数等.但问题是控制器中的 ...

  9. protobuf-net 与 C#中几种序列化的比较

    C#中几种序列化的比较,此次比较只是比较了 序列化的耗时和序列后文件的大小. 几种序列化分别是: 1. XmlSerializer 2. BinaryFormatter 3. DataContract ...

  10. 尝试在Linux上编译KestrelHttpServer

    Kestrel是目前在非Windows平台上运行ASP.NET 5应用程序的唯一可用Web服务器,但微软似乎将它冷落在一边,源代码更新很慢. 今天试着在Linux上编译Kestrel的源代码,遇到了很 ...