与Android活动的动画 [英] Animation between Activity with Android

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

问题描述

我需要了解动画在Android上。

i need to understand animation on Android.

例如,与在底部的一个按钮,一个活动我的应用程序启动时的按钮,用户点击我想另一个活动似乎从底部动画顶部,我想,该按钮变成了头对本次活动。

For example, my application starts with an activity with a button in the bottom, when the user click on the button i want that another activity appears with an animation from bottom to top and i want that the button becomes the "header" of this second activity.

我怎样才能做到这一点?

How can i achieve this?

感谢您

丹尼尔

感谢您给De codeGnome的答案!它的工作原理!

Thank you to DecodeGnome for the answer! It works!

但我有一些问题与动画,当我想关闭此活动中,我创建了一个anim_out.xml:

But i have some problem with the animation when i want to close this activity, i create a anim_out.xml:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
    android:fromXDelta="0%p"
    android:fromYDelta="0%p"
    android:toXDelta="0"
    android:toYDelta="100%p"
    android:duration="300" />
 </set> 

,但这不工作(overridePendingTransition什么是用于第二参数α)。

but this doesn't work (the second parameter of overridePendingTransition what is used for?).

我试图调用的onStop新overridePendingTransition()函数:

I try to call a new overridePendingTransition in onStop() function:

public void onStop(){
   super.onStop();
   overridePendingTransition(R.anim.top_to_bottom, R.anim.top_to_bottom);

}

但是,当我打电话完成的第二个活动,我仍然看到默认的动画(从左至右)!

But when i call finish to the second activity, i still see the default animation (from left to right)!

再次感谢你谁就会帮助我。

Thank you again to who'll help me.

推荐答案

1)创建一个名为阿尼姆的资源文件夹中的文件夹

1) Create a folder called anim in res folder

2)添加两个新的XML动画那里(例如,anim_in.xml和放大器; anim_out.xml)

2) Add 2 new XML animations there (example, anim_in.xml & anim_out.xml)

3)把此行的code。在新的活动的onCreate:

3) put this line of code in the new activities onCreate:

overridePendingTransition(R.anim.anim_in,R.anim.anim_out);

overridePendingTransition(R.anim.anim_in, R.anim.anim_out);

Anim_in.xml例如:

Anim_in.xml example:

<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android">

    <translate
        android:fromXDelta="0%p"
        android:fromYDelta="100%p"
        android:toXDelta="0"
        android:toYDelta="0%p"
        android:duration="300" />
</set> 

4)将在所述第二活动的布局的顶部的按钮(头)。

4) Place the button (header) in the top of the layout of the second activity.

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

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