淡出动画上活动转型 [英] Fade in animation on Activity Transition

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

问题描述

我codifiying我的标志活动与我的主要业务之间的过渡效果,但我之前消失的活动转移到顶部的问题:

I am codifiying a transition effect between my logo activity and my Main activity, but I have the problem that before vanish the activity move to top:

<?xml version="1.0" encoding="utf-8"?>

<alpha
    android:duration="2000"
    android:fromAlpha="0.0"
    android:toAlpha="1.0" >
</alpha>

我怎么能改善这个code只得到一个清漆效果?

How could I improve this code to get only a vanish effect?

推荐答案

您可以使用这两个.xml文件淡入一个新的活动,并淡出了当前活动。

You could use those two .xml files to fade in a new Activity and fade out the current Activity.

fade_in.xml

fade_in.xml

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
           android:interpolator="@android:anim/accelerate_interpolator"
           android:fromAlpha="0.0" android:toAlpha="1.0"
           android:duration="500" />

fade_out.xml

fade_out.xml

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
           android:interpolator="@android:anim/accelerate_interpolator"
           android:fromAlpha="1.0" android:toAlpha="0.0"
           android:fillAfter="true"
           android:duration="500" />

使用它在code这样的:(在你的活动)

Use it in code like that: (Inside your Activity)

Intent i = new Intent(this, NewlyStartedActivity.class);
startActivity(i);
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);

以上code将淡出当前活动的活动和淡入新启动的活动。

The above code will fade out the currently active Activity and fade in the newly started Activity.

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

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