简体   繁体   English

Xamarin 启动画面 Android 11 VS Android 12

[英]Xamarin Splash Screen Android 11 VS Android 12

I am trying to get a xamarin.android app to show a splash screen.我正在尝试让 xamarin.android 应用程序显示启动画面。 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.它在我的 Pixel 3a android 11 上运行良好,但它不适用于 android 12。我在 Pixel 6 和 S21 Ultra 上遇到了同样的问题。 I did find this on github but I have not found anything else on how to get around this issue我确实在 github 上找到了这个,但我还没有找到任何其他关于如何解决这个问题的方法

Documented Issue https://github.com/xamarin/xamarin.android/issues/6517记录在案的问题https://github.com/xamarin/xamarin.android/issues/6517

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

styles.xml 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

<?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 Android 11 启动画面

安卓 11

Android 12 Splash Screen Android 12 启动画面

安卓 12

Run this code on a android 11 device then run it on a android 12 device在 android 11 设备上运行此代码,然后在 android 12 设备上运行它

安卓 11 启动

When I try the suggestion in the github issue I get these runtime errors当我尝试 github 问题中的建议时,出现了这些运行时错误

Github https://github.com/MicahArmantrout/SplashScreen/tree/main/ScreenTest%20WithBindingAlpha 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 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如果有人让它完全工作,请告诉我,我会更新我的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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