[英]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.