简体   繁体   中英

Xamarin Splash Screen Android 11 VS Android 12

I am trying to get a xamarin.android app to show a splash screen. It worked fine on my Pixel 3a with android 11 but it does not work with android 12. I get the same problem with the Pixel 6 and S21 Ultra. I did find this on github but I have not found anything else on how to get around this issue

Documented Issue https://github.com/xamarin/xamarin.android/issues/6517

Repro to reproduce https://github.com/MicahArmantrout/SplashScreen

styles.xml

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="android:windowBackground">@drawable/splash_screen</item>
        
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar" />

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.MaterialComponents.Light" />

</resources>

SplashScreen.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:gravity="center"
    android:layout_height="match_parent"
    android:layout_width="match_parent">
    <item>
        <bitmap
          android:src="@drawable/splash"
          android:tileMode="disabled"
          android:gravity="center" />
    </item>

</layer-list>

Android 11 Splash Screen

安卓 11

Android 12 Splash Screen

安卓 12

Run this code on a android 11 device then run it on a android 12 device

安卓 11 启动

When I try the suggestion in the github issue I get these runtime errors

Github https://github.com/MicahArmantrout/SplashScreen/tree/main/ScreenTest%20WithBindingAlpha

I have updated my repro with a potential solution with two issues

  • the screen looks zoomed in (maybe this can be fixed messing with image sizes)

  • there is a colored screen right before the splash screen shows

https://github.com/MicahArmantrout/SplashScreen/tree/main/SplashScreen

if anyone gets this to fully work please let me know and I will update my solution

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