在两个活动的Android翻盖卡过渡 [英] Flip card transition between two activities Android
问题描述
我试图实施翻转卡
过渡我的应用程序两项活动之间通过采取帮助作用:
<一href="http://blog.robert-heim.de/karriere/android-startactivity-rotate-3d-animation-activityswitcher/" rel="nofollow">http://blog.robert-heim.de/karriere/android-startactivity-rotate-3d-animation-activityswitcher/.
But我不明白是什么 ActivitySwitcher.java
和 Roatate3dAnimation.java
在上述网站。我在我的应用程序的两项活动之间的人我想给这个过渡效果。他们是 MainActivity.java
和 About_us.java
。请参照说明code我活动。我还搜查 http://developer.android.com/training/animation/cardflip.html 但不成功,因为它不是为活动。
谢谢!
I am trying to implement the Flip card
transition effect between two activities in my app by taking help from :
http://blog.robert-heim.de/karriere/android-startactivity-rotate-3d-animation-activityswitcher/.
But I couldn't understand what areActivitySwitcher.java
and Roatate3dAnimation.java
in the above mentioned site. I have two activities in my app between whom I want to show this transition effect. They are MainActivity.java
and About_us.java
.
Please explain the code with reference to my activities. I also searched on http://developer.android.com/training/animation/cardflip.html but in vain as it not for activities.
Thanks!
推荐答案
有这样做,我发现了一个非常简单的方法。首先,确保你有一个在你的资源文件夹,您的项目称为动画的文件夹。然后,你需要创建两个XML文件(我有我叫from_middle和to_middle)。下面是code为每个的:
There is a very simple way of doing this that I have found. First, make sure that you have a folder called anim under your res folder for your project. Then you will need to create two xml files (I have mine called from_middle and to_middle). Below is the code for each of those:
from_middle.xml:
from_middle.xml:
<?xml version="1.0" encoding="utf-8"?>
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="0.0" android:toXScale="1.0"
android:pivotX="50%"
android:fromYScale="1.0" android:toYScale="1.0"
android:pivotY="50%"
android:duration="500" />
to_middle.xml:
to_middle.xml:
<?xml version="1.0" encoding="utf-8"?>
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="1.0" android:toXScale="0.0"
android:pivotX="50%"
android:fromYScale="1.0" android:toYScale="1.0"
android:pivotY="50%"
android:duration="500" />
这些被创建后,所有你需要的是一行code来运行这个动画,您应该放在你开始你的下一个活动后:
After those are created, all you need is one line of code to run this animation, which you should be placed after you start your next activity:
overridePendingTransition(R.anim.from_middle, R.anim.to_middle);
运行它,你应该看到预期的效果!
Run it, and you should see the desired results!
这篇关于在两个活动的Android翻盖卡过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!