如何让启动画面变成全屏?

How can I make splash screen to full screen?

我正在尝试将启动画面设为全屏。让我用图片解释一下:

如您所见,顶部有一个黑条。底部还有一个白色的导航栏。顶部的黑条在打开应用程序几秒钟后出现,导致背景图像尺寸减小。

我的splash_screen.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <color android:color="@color/splash_background"/>
    </item>
    <item android:gravity="fill">
        <bitmap
             android:tileMode="disabled"   
             android:gravity="fill"
             android:mipMap="true"
             android:src="@drawable/splash_logo"/>
    </item>
</layer-list>

我的styles.xml:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
    <style name="MyTheme.Splash" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@drawable/splash_screen</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowActionBar">false</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>

我的SplashActivity.cs:

namespace OkuKazan
{
    [Activity(Label = "OkuKazan", Icon = "@mipmap/icon", Theme ="@style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
    public class SplashActivity : Activity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Create your application here
        }

        protected override async void OnResume()
        {
            base.OnResume();
            await SimulateStartUp();
        }

        async Task SimulateStartUp()
        {
            await Task.Delay(TimeSpan.FromSeconds(3));
            StartActivity(new Intent(Application.Context, typeof(MainActivity)));
        }
    }
}

根据我的研究,他们正在使用 NavigationPage 之类的东西,但由于我是新的 xamarin 用户,所以我不明白。如果您能提供帮助,我将不胜感激。

编辑 1:

我编辑了 styles.xml,但它仍然无法正常工作。顶部的黑条和白条没有消失:(

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>m>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="windowActionModeOverlay">false</item>
        <item name="android:windowBackground">@android:color/white</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:textCursorDrawable">@null</item>
        <item name="android:forceDarkAllowed">false</item>
    </style>

    <style name="MyTheme.Splash" parent="AppTheme">
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowBackground">@drawable/splash_screen</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</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>

主题看起来像:

  <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>m>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="windowActionModeOverlay">false</item>
    <item name="android:windowBackground">@color/white</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:textCursorDrawable">@null</item>
    <item name="android:forceDarkAllowed">false</item>
  </style>

  <style name="AppTheme.Splash" parent="AppTheme">
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowBackground">@drawable/bg_splashscreen</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
  </style>

然后在 Activity 上使用 AppTheme.Splash。这适用于我使用的其中一个应用程序。你可以玩弄属性。然而,windowFullScreenwindowNoTitle 可能是最重要的。