animated transition between an activity and another [closed]

眉间皱痕 提交于 2019-12-18 13:26:06

问题


I state that i'm not very experienced in android, and I would like to understand, perhaps with some tutorial, how to implement any scrolling animation between one activity and another. I hope in your help


回答1:


You can set up animations (like slide) when you switch between activities like this :

In the res folder, create an anim folder

For example, put two xml files for a slide effect :

slide_in.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:shareInterpolator="false">
    <translate 
       android:fromXDelta="100%" android:toXDelta="0%"
       android:fromYDelta="0%"   android:toYDelta="0%"
       android:duration="200"/>
</set>

slide_out.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:shareInterpolator="false">
    <translate
       android:fromXDelta="100%" android:toXDelta="0%"
       android:fromYDelta="0%" android:toYDelta="0%"
       android:duration="200" />
</set>

Then on your java code just write this :

Intent i = new Intent(YourActivity.this, OtherActivity.class);
this.startActivity(i);
overridePendingTransition(R.anim.slide_in, R.anim.slide_out);

If you are testing that on a real device, don't forget to allow it to play animations (Settings -> Display -> Animations -> All Animations)

Hope it helps ! :)



来源:https://stackoverflow.com/questions/12092894/animated-transition-between-an-activity-and-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!