活动和其他的动画过渡 [英] animated transition between an activity and another

查看:111
本文介绍了活动和其他的动画过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的状态,我不是非常有经验的机器人,我想明白了,也许一些教程,如何实现一个活动和另一个之间的滚动动画。我希望在您的帮助

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

推荐答案

您可以设置动画(如幻灯片)当你活动之间的切换是这样的:

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

RES 文件夹中,创建一个动画文件夹

In the res folder, create an anim folder

例如,将两个 XML 文件幻灯片效果:

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

slide_in.xml

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

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>

然后在你的java code只是写:

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 Animation)

希望它帮助!)

这篇关于活动和其他的动画过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆