Original theme broken with API Splashscreen Android 12 (only MainActivity)

Viewed 46

I added the new Splashscreen API (androidx.core:core-splashscreen:1.0.0-rc01) on my app, after that my margins/paddings are broken but only for my launcher activity (MainActivity) especially for alert dialogs opened from this activity. In other activities, no problem, everything is working fine.

Below, my alertdialog without the Splashscreen implemented, my paddings/margins are OK : Margin and padding OK without Splashscreen

And now with Splashscreen implementation :

[Margin and padding broken withSplashscreen2

I followed instructions from the developer Android doc here : https://developer.android.com/reference/kotlin/androidx/core/splashscreen/SplashScreen

In my MainActivy.kt

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

In the Manifest.xml, I added the code below in my MainActity

android:theme="@style/AppTheme.AppStarting"

In my Splashscreen theme, I have set the "postSplashScreenTheme" to my original theme

<style name="AppTheme.AppStarting" parent="Theme.SplashScreen">
    <item name="postSplashScreenTheme">@style/AppTheme</item>
    <item name="windowSplashScreenBackground">@color/white</item>
    <item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher_foreground</item>
</style>

And to finish, my alertdialog is the same XML using everywhere in my app with padding in a RelativeLayout :

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingStart="@dimen/activity_horizontal_margin"
    android:paddingEnd="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin">

Any idea ? Maybe it's a bug because this API is in release candidate, not final release ? It's seems like the tag "postSplashScreenTheme" is not working correctly when the Splashcreen disapeared. I found this post where the problem seems to be similar but no solution : Android 12 SplashActivity theme breaks CardView style

0 Answers
Related