Android的左到右幻灯片动画 [英] Android Left to Right slide animation

查看:233
本文介绍了Android的左到右幻灯片动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个活动,其推出的模式是单个实例。
使用 onfling(),我摇摆他们的左,右。

I have three activities whose launch modes are single instance.
Using onfling(), I swing them left and right.

现在的问题是,当我刷卡从右到左的幻灯片切换是好的,但是当我刷卡左到右,我得到刷卡从右到左的过渡。

The problem is when I swipe right to left the slide transition is okay but when I swipe left to right, I get the transition of swiping right to left.

我知道这是为什么发生的,因为我一直在发送新的意图。不过,现在我需要改变滑动左到右的动画。

I know why this is happening its because I am always sending new intents. But, now I need to change the animation of sliding left to right.

我知道有一个名为方法 overridingTransitionPending(),但我不知道如何定义我的动画XML。

I know there is a method named overridingTransitionPending(), but I do not know how to define my animation in XML.

推荐答案

使用此XML在 RES /动画/

这是为从左向右动画:

<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="700"/>
</set>

这是从右到左的动画:

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

在你的编码使用意图像左到右:

In your coding use intent like for left to right:

this.overridePendingTransition(R.anim.animation_enter,
                   R.anim.animation_leave);

在像从右到左的编码的使用意图

In your coding use intent like for right to left

this.overridePendingTransition(R.anim.animation_leave,
                               R.anim.animation_enter);

这篇关于Android的左到右幻灯片动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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