[英]How to change the screen before the splash screen?
在我的自定義啟動屏幕顯示在我的 webview 上之前,我的 mipmap 徽標的前景與灰色背景一起顯示(啟動屏幕從onCreate()
顯示):
我想將背景顏色更改為白色,並且如果可能的話,將圖像更改為而不是應用程序圖標的前景,同時顯示背景和前景,使其顯示為完整的徽標。 這可能嗎? 如果是這樣,怎么辦?
這是我的一些代碼:
AndroidManifest
:
<application
....
android:icon="@mipmap/ic_favicon_1144_round"
....
ic_favicon_1144_round
:
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_favicon_1144_background"/>
<foreground android:drawable="@drawable/ic_logo_48_foreground"/>
</adaptive-icon>
順便說一句,我還沒有編寫任何代碼來專門顯示前景或灰色背景。 如果您想查看更多代碼,只需發表評論,我將在我的問題中進行編輯。 即使您無法回答整個問題,對此的任何幫助都會非常感激:謝謝:)
如果您使用的是android 12及以上,我建議您使用最新的啟動畫面
你應該在你的主題中添加這個代碼theme.xml
</style>
<style name="Theme.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/purple_700</item>
<item
name="windowSplashScreenAnimatedIcon">@drawable/ic_round_local_movies_24</item>
<item name="windowSplashScreenAnimationDuration">1000</item>
<item name="postSplashScreenTheme">@style/Theme.MoviesApp</item>
</style>
你可以在這里調整圖標和背景
當然,您應該將此代碼添加到activity section
的manifest
文件中
android:theme="@style/Theme.Starting"
這段代碼在你的主要活動中,在 onCreate 之后和 setContent 視圖之前
val splashScreen = installSplashScreen()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.