淡入活动从Android的previous活动 [英] Fade in Activity from previous Activity in Android

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

问题描述

我目前工作的一个Android应用程序,我有我的防溅活动的一些问题。我想我的主要活动,从我泼活动渐显,而不是黑屏。我的两个飞溅和主要活动使用相同的背景图片,所以如果我做了fade_in / fade_out组合,它看起来怪异的那种为背景的过渡过程中消失了一点。

I am currently working on an Android app and I am having some issues with my splash activity. I want my main activity to fade in from my splash activity, not from a black screen. Both my splash and main activities use the same background image so if I do a fade_in/fade_out combo, it looks weird as the background kind of fades a bit during the transition.

这里的想法是我有我的标志版本:正常发光。我想我的主要活动淡入所以我发光的标志在需要我的正常的标志引起了整洁的小打开的效果。下面code,从一个黑色的屏幕,这是不理想的淡入

The idea here is I have to versions of my logo: normal and glowing. I want my main activity to fade in so my glowing logo over takes my normal logo causing a neat little "turn on" effect. The following code fades in from a black screen, which is not ideal.

/**
 * Pause Activity
 */
@Override
protected void onPause()
{
    super.onPause();
    finish();
    overridePendingTransition(android.R.anim.fade_in, 0);
}

编辑:

创建我自己的fade_out动画保留了1.0阿尔法水平(1.0至1.0),并添加安卓fillAfter =真正的来我泼的动画设定固定的问题

Creating my own fade_out animation to retain the 1.0 alpha level (from 1.0 to 1.0) and adding android:fillAfter="true" to my splash animation set fixed the issue.

推荐答案

这是关于事物的秩序。这是在3秒后消失到下一个活动的一个例子:

It is about the order of things. Here is an example which fades into next activity after 3 seconds:

new Handler().postDelayed(new Runnable() {
  @Override
  public void run() {

    //Create an intent that will start the main activity.
    Intent mainIntent = new Intent(SplashActivity.this, MainMenuActivity.class);
    SplashActivity.this.startActivity(mainIntent);

    //Finish splash activity so user cant go back to it.
    SplashActivity.this.finish();

    //Apply splash exit (fade out) and main entry (fade in) animation transitions.
    overridePendingTransition(R.anim.mainfadein, R.anim.splashfadeout);
  }
}, 3000);

请注意,这里有两个动画淡入和淡出。

Note that here there a two animations fade in and fade out.

mainfadein.xml

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

splashfadeout.xml

splashfadeout.xml

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

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

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