</pre>随便写了几个Activity作为测试<p></p><p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOcAAABUCAYAAAB5qiD7AAAUsUlEQVR4Ae1dDXAc5Xl+Tja0jZsE1zhkalPHRjLG0cS4mBYkIIN/oJLSsTx15fHEoDRpTgaSSgXkAaIUaGWSQcnkbpi60QXaGJO61lB8cfUT/EcIlZLUAWJGUV2fbDCEkE5sU3vsdrBPt33fb/++Xe3t7d7pTifr2/F6f77v/dln99333d37HkU0mqAmhYBCoOwQqCg7j5RDCgGFgEBABae6EBQCZYqACs4yPTHKLYWACk51DSgEyhSBmaX069+6lvua+9P2133bVaNCYFohwG9rSzXt/vpy7YMLac95eM892p4nry+VK7qdVEyrQY0WS/mYDdLHR9y7qV+LIqr1eze69nLfHD66JMZtFuUYxllROyYYgZKWtWNaJOuN7/JZc3DNkpuRK7s6FYwiXhtBpGXAubtstsrdv7IBSjnigUDo4BwaGsL58+c9VOXelabgzNBXVXN+7b0zWLY5gfu3/RAcnJfRvGjJTeh5YkVuZdxjtA89oNyXSCJYeOrBYsVyZSsGtUG0VvqYc/RxyfuIiabQ/uVSmGe74xjy1KHESo5A6OA8ceIEent7cerUqdDOpscoOCkyeaYKwCE/9/ovYX7to1h4x1PgIA4yjfb1AE3b0RFNIBksOoOonbA+5e7fhB2oUlQUBEIHJ3uxcuVK7N69G++++24opy5KmTOdcYpmxoAxmjO0/2ImSHCOQsRmQyXqGqNIdMYx6lA5gJYIlbzGXBuP03YV2oaARD3tr6X+o3HURloo6+oZsTZuaxiN17r6sD5ZvgUtVFLLMhho0WWEH7n8M501s7HTXyu7m936SLd5PHKjOAb7OOUmUxTWcRp7PGV8MGAxTxnLglopAgJ5BefcuXOxbt06PP/880ilUoHd4uDTZ86eTrExyqRjtI+DljNszmmgC21oAsUmKDoRHepBnxVbfKHXYziWEhmas/Rgayu6tRRiNUC0nzL3YCvsarYSrR1RDPX0GQHOgTWEaIfcp84l341uhwwwkEzYMr7+jT+6RH0SjeQ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Z63X6as7NafoSHXK+8CdvUPkL91ePQnMRzdqNtYclUSC7jEJbrK29bWYBfvb4jjLTZGk2VjYQP+hAJ813Ud2LTQxsruM14+s7AVm68jGXr+vc1TRpgIdOwZL/s+eLHfaioNAqF/+B6UQ2jrvx7H3SsX4ewH9oF8/xu3YtMWSi00oGHk1ydFw9KPXymWfNIjxn87nlyDxgdesQXV2jgEXmmPoLsqhefoBjBuejOOTTUjaHmvG7eOayxsx0d+C3j24HF85c8WFaZISedEIPTP98JwCIlsJ91q+U1shmo0jT6pLPnYHHJO/+5pesn9+XbPLzTM0sxsU0sJAQq+7ueiiP6KMrOEr9nj7X09+PmKJlzNWJo7J2g50fomyK1LUk3o4AyDAl838rUThkNIlgtj81Lv++9bIrjvOWD9cxpqXfjiYAuWbeI30VH8/a9acbW7fQLAUedlAkAMqCJ0WRtQL77VewL1N86nHxTMEG8wg8qpfuWLwAx6HLmsYgz9h36Jv/7MgvJ19BLxrGiZ87p5s3DknTP45IIrMJOGGalp6iOQpueSX5w4g2t//0NT/2CmwBEULXNeoBO59+enBE2JGv83Ba6EAC5ePjMiaEruuH6OGNcZQER1KQCBogVnAT4pUYWAQoAQUPWmugwUAmWKwP8DIq02YUfDCzYAAAAASUVORK5CYII=" alt="" /></p><p>布局就不多说了,一行字就好,加个颜色也行。</p><p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQIAAABhCAYAAAA9WK8QAAAXgElEQVR4Ae1dfXBUVZb/NQHkQ0asWQUtFZQONQthR8oZh0ocFnBUkjhOdB3cqf0jrDqdcokmI2bVqRS1tZVydjaoHRFnk3JYszXl1kZ3Jn6QVtZh0TUZkNWZVYxANzOIgnwLKAYInbfn3Pfu6/f643V3Pjp9O/cWj9fv3nPOPff33j3v3vve+8VnUEKO0ttrv+Oq6YaHtrmOMz8IocbXiSqjFeWZK2lJjYBGIAUC41PkD3v2r+8vxh3rwi67yfJcAnl5EEFLWTF6Gw206iiUl2dIO5U9AkMKBFu2bMG2bdv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B+K4lfw5VsxbF9jaAyz/l1oisscASUeqFo/95duHLxUhRd+jX8uPYO2l+BcRMmgvO3Rz/QnIUFfrHq5o0cAkpNDQ5sbcfHm59IQGPWsgdx+aLqhHydoRHQCGSGgFKBILMmaSmNgEYgWwTUWiPItnVaXiOgEcgIAR0IMoJJC2kEChsBHQgK+/zq1mkEMkLg/wHjwDTYnvoa6QAAAABJRU5ErkJggg==" alt="" /></p><p>MainActivity的布局:3个Button,点击后,分别跳转到不同的Activity。</p><p></p><pre name="code" class="java"><Button
android:id="@+id/btn1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="Alpha Aniamtion"
/>
<Button
android:id="@+id/btn2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="Translate Animation"
/>
<Button
android:id="@+id/btn3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="Translate slide from right to left"
/>
一开始采取了比较麻烦的方法,
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn1:
Intent intent_alpha = new Intent(MainActivity.this, ActivityAlpha.class);
startActivity(intent_alpha);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
break;
case R.id.btn2:
Intent intent_trans = new Intent(MainActivity.this, ActivityTranslation.class);
startActivity(intent_trans);
overridePendingTransition(android.R.anim.slide_in_left,android.R.anim.slide_out_right);
break;
case R.id.btn3:
Intent intent_slide = new Intent(MainActivity.this, ActivityTranslation.class);
startActivity(intent_slide);
overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
break;
default:
break;
}
}
在每个startActivity()方法后面加上 overridePendingTransition(android.R.anim.XXin, android.R.anim.XXout);
这两个参数跟别是即将进入的新的Activity要执行的动画,和即将看不见的原来的Activity要执行的动画。
同样,别忘了,在新的Activity退出时也要执行动画的话,可以覆写onKeyDown方法。
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK) {
this.finish();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
return false;
}
这次是在finish的后面加上那个方法。如果在一些非Activity类中调用的话,fragment啥的,因为调用者是Activity(我猜),就在前面加getActivity(),getParent()啥的就行啦。
这里用到的有几个是android自带的动画的方法。
如果要自己写的话,可以在res里面新建文件夹anim,在里面新建动画的xml,如:
in_from_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator" >
<translate
android:duration="500"
android:fromXDelta="100%p"
android:toXDelta="0%p" />
</set>
集合set里面可以添加多种属性的动画,translate,scale,alpha等。
——————————————————————————————分————割————线————————————————————————————————
另外一种实现的方法是,在style中声明一个style,并在想要执行动画的Activity的Manifest文件中设置theme
<style name="XXXX" parent="@android:style/XXXXX" mce_bogus="1">
<item name="android:activityOpenEnterAnimation">@anim/push_left_in</item> <span style="color:#ff0000;">打开</span>Activity时,<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color:#ff0000;">即将进入</span>的Activity执行的动画</span>
<item name="android:activityOpenExitAnimation">@anim/push_left_out</item> <span style="color:#ff0000;"> </span><span style="font-family: Arial, Helvetica, sans-serif;"><span style="color:#ff0000;">打开</span>Activity时,</span><span style="font-family: Arial, Helvetica, sans-serif;"><span style="color:#ff0000;">即将退出</span>的Activity执行的</span><span style="font-family: Arial, Helvetica, sans-serif;">动画 </span><span style="font-family: Arial, Helvetica, sans-serif;"> </span>
<span style="font-family: Arial, Helvetica, sans-serif;">
</span><item name="android:activityCloseEnterAnimation">@anim/push_right_in</item> <span style="color:#ff0000;">退出</span>Activity时,<span style="color:#ff0000;">即将进入</span>的Activity执行的动画
<item name="android:activityCloseExitAnimation">@anim/push_right_out</item> <span style="font-family: Arial, Helvetica, sans-serif;"><span style="color:#ff0000;">退出</span>Activity时,<span style="color:#ff0000;">即将退出</span>的Activity执行的动画</span>
</style>
这个stlye可以继承自系统自带的一些style,但是不一定会有什么后果0.0