簡體   English   中英

Xamarin 啟動畫面 Android 11 VS Android 12

[英]Xamarin Splash Screen Android 11 VS Android 12

我正在嘗試讓 xamarin.android 應用程序顯示啟動畫面。 它在我的 Pixel 3a android 11 上運行良好,但它不適用於 android 12。我在 Pixel 6 和 S21 Ultra 上遇到了同樣的問題。 我確實在 github 上找到了這個,但我還沒有找到任何其他關於如何解決這個問題的方法

記錄在案的問題https://github.com/xamarin/xamarin.android/issues/6517

Repro 轉載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>

啟動畫面.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 啟動畫面

安卓 11

Android 12 啟動畫面

安卓 12

在 android 11 設備上運行此代碼,然后在 android 12 設備上運行它

安卓 11 啟動

當我嘗試 github 問題中的建議時,出現了這些運行時錯誤

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

我已經用一個有兩個問題的潛在解決方案更新了我的復制品

  • 屏幕看起來放大了(也許這可以解決圖像尺寸的問題)

  • 在啟動畫面顯示之前有一個彩色屏幕

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

如果有人讓它完全工作,請告訴我,我會更新我的解決方案

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM