我试图添加一个闪屏与新的Android API.问题是,我的应用程序上工作有一个奇怪的白色闪屏与应用程序的标志,但我不能在所有的代码中看到的地方正在引入,和自定义我想把没有出现.
这是SplashActivity的代码(该类在清单中显示为LAUNCHER,在意图中显示为MAIN
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
Firebase.inAppMessaging.setMessagesSuppressed(true)
initStetho()
initTracker()
setUpToolbar()
checkDynamicLink()
updateTaxonomies = true
}
字符串
onResume只验证演示者类的数据。
这是申请清单
<application
android:name=".B4workApp"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_app_adaptive_icon"
android:label="@string/app_name"
android:largeHeap="true"
android:roundIcon="@mipmap/ic_app_adaptive_icon_round"
android:theme="@style/Theme.App.Starting">
型
以及启动器活动
<activity
android:name=".newcode.presentation.splash.SplashActivity"
android:clearTaskOnLaunch="true"
android:exported="true"
android:largeHeap="true"
android:launchMode="singleTask"
android:screenOrientation="unspecified"
android:theme="@style/AppThemeTransparentStatus">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
型
除了用于可浏览类别和来自后端的关联数据之外,还有其他意图过滤器标签。
最后是涉及的主题:
AppTheme
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/transparent</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/emperor</item>
<!-- colorAccent is used as the default value for colorControlActivated,
which is used to tint widgets -->
<item name="colorAccent">@color/emperor</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight, and colorSwitchThumbNormal. -->
<item name="android:textColor">@color/gray</item>
<item name="android:textColorPrimary">@color/gray</item>
<item name="android:textColorSecondary">@color/emperor</item>
<item name="android:actionMenuTextColor">@color/emperor</item>
<!-- Support library compatibility -->
<item name="android:actionMenuTextAppearance">@style/customActionBar</item>
</style>
型
AppThememeEventStatus
<style name="AppThemeTransparentStatus" parent="AppTheme">
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/transparent</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/transparent</item>
<!-- colorAccent is used as the default value for colorControlActivated,
which is used to tint widgets -->
<item name="colorAccent">@color/emperor</item>
<item name="android:textColor">@color/gray</item>
<item name="android:textColorPrimary">@color/gray</item>
<item name="android:actionMenuTextColor">@color/gray</item>
<!-- Support library compatibility -->
<item name="android:actionMenuTextAppearance">@style/customActionBar</item>
</style>
型
Splash主题
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/black</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/b4w_splash_icon_anim</item>
<item name="windowSplashScreenAnimationDuration">3000</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>
型
drawable是一个动画矢量drawable作为docs说,但没有任何动画,我已经尝试了简单的矢量太多,因为YouTube教程做他们和工作。
但在开始的时候,
的数据
我已经审查了应用程序的所有模块和所有风格,我不明白为什么出现白色屏幕
更新:如果需要logcat消息:
2023-12-22 09:52:52.517 900-957 SplashScreenView com.android.systemui D Build android.window.SplashScreenView{1903f10 V.E...... ......ID 0,0-0,0}
Icon: view: android.widget.ImageView{401ea09 V.ED..... ......I. 0,0-0,0 #10204a7 android:id/splashscreen_icon_view} drawable: com.android.wm.shell.startingsurface.SplashscreenIconDrawableFactory$ImmobileIconDrawable@615940e size: 504
Branding: view: android.view.View{b207e2f G.ED..... ......I. 0,0-0,0 #10204a6 android:id/splashscreen_branding_view} drawable: null size w: 0 h: 0
型
似乎没有很好地建立起来,但不知道为什么
编辑:解决了,我只需要修改我的styles.xml,现在它对apis 31和更高版本可见,使用本教程:https://medium.com/@radomir9720/android-splash-screen-easy-setup-for-both-11-version-and-lower-and-12-287ccb86f9c7
1条答案
按热度按时间q0qdq0h21#
尝试在
super.onCreate(savedInstanceState)
之前调用installSplashScreen()
:字符串
在onCreate方法中,启动Activity,**在super.onCreate()**之前调用installSplashScreen。您还需要确保postSplashScreenTheme设置为应用的主题。或者,如果不需要SplashScreen示例,则可以将此调用替换为Activity#setTheme。