简体   繁体   中英

Android: Splash Screen API showing empty

I am trying to impelement a splash screen.

I have followed the splash screen api approach implemented the implementation "androidx.core:core-splashscreen:1.0.0-alpha01"

then used the following style

<style name="SplashTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        <item name="windowSplashScreenBackground">@color/black</item>
        <item name="windowSplashScreenAnimatedIcon">@drawable/ic_search</item>
        <item name="postSplashScreenTheme">@style/Theme.AppTheme</item>
    </style>

then set the theme in the mainActivity in the manifest.xml

 <activity
            android:name=".ui.main.MainActivity"
            android:exported="true"
            android:theme="@style/SplashTheme"
</activity>

and used the method intallSpalshScreen in the onCreated func

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        installSplashScreen()

        toolbar = binding.viewToolbar.tbToolbar

compileSDKVersion in 31

截屏

But the splash screen just shows a blank screen

Is there something i missed or any other way around this please let me know.

I guess you need to change the parent of the splashTheme from

parent="Theme.AppCompat.DayNight.NoActionBar"

to

 parent="Theme.SplashScreen"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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