繁体   English   中英

启动画面显示在主要活动的背景上

[英]Splash screen showing on the background of main activity

我已使用此指南在应用程序上设置了初始屏幕。

我的应用程序的背景是过渡色(使用动画列表每隔几秒钟更改一次颜色)。

显示启动屏幕后(在应用程序启动时),它停留在主要活动的背景中。

截图

这是spalsh_screen.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@android:color/white"/>
    <item>
        <bitmap
            android:src="@drawable/talki_logo_big"
            android:gravity="center"/>
    </item>
</layer-list>

这是animation_list.xml

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
android:visible="true">
    <item
        android:drawable="@drawable/gradient_background_1"
        android:duration="2500" />
    <item
        android:drawable="@drawable/gradient_background_2"
        android:duration="2500" />
    <item
        android:drawable="@drawable/gradient_background_3"
        android:duration="2500" />
    <item
        android:drawable="@drawable/gradient_background_4"
        android:duration="2500" />
    <item
        android:drawable="@drawable/gradient_background_5"
        android:duration="2500" />
</animation-list>

有没有办法使启动画面消失?

谢谢! :)

尝试在清单中为启动画面活动添加属性android:noHistory="true"

值为“ true”表示该活动将不会留下历史痕迹。 它不会保留在任务的活动堆栈中,因此用户将无法返回至该任务,并且可能不会在后台显示。

您链接的教程中已经有解决方案。

转换回常规主题的最简单方法是在super.onCreate()setContentView()之前调用setTheme(R.style.AppTheme) setContentView()

public class MyMainActivity extends AppCompatActivity {
 @Override
  protected void onCreate(Bundle savedInstanceState) {
    // Make sure this is before calling super.onCreate
    setTheme(R.style.Theme_MyApp);
    super.onCreate(savedInstanceState);
    // ...
  }
}

失败原因

您已在清单中设置了AppTheme.Launcher ,它为Activity提供了背景。 现在,开始活动后,您需要将该主题更改为您的应用程序主题,以删除启动画面背景。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM