首页 > 解决方案 > (Android) 在 Xamarin Forms 3.3 上更改模块时总是显示启动画面?

问题描述

Xamarin Forms使用3.3 版时遇到问题。在Android上,当切换模块(示例模块Home)时,Splash Screen总是显示(我在Android上的每个屏幕之间遇到这个问题)。(在 iOS 上,完美运行)

开关模块

启动画面

Xamarin Forms2.5 版本上,它没有这个问题。

Splash Screen在 Xamarin Forms 3.3 上切换模块时如何防止显示。

我试过了,但它不起作用。 ANDROID:SPLASH:为什么我在应用程序恢复时总是看到启动画面

这是我的代码:

<style name="MyProject" parent="MyProject.Base">
   <item name="android:windowBackground">@drawable/splash_screen</item>
   <item name="android:windowFullscreen">true</item>
   <item name="android:buttonStyle">@style/noPaddingButtonStyle</item>
   <item name="android:editTextStyle">@style/noPaddingEditTextStyle</item>
 </style>

并在以下位置使用它MainActivity.cs

[Activity(Label = "MyProject",
    Theme = "@style/MyProject",
    Icon = "@drawable/ic_launcher",
    LaunchMode = LaunchMode.SingleInstance,
    Name = "com.myproject.mobile.MainActivity",
    MainLauncher = true,
    ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
    WindowSoftInputMode = SoftInput.AdjustPan)]

谢谢!

标签: androidxamarinxamarin.formsxamarin.androidsplash-screen

解决方案


您在 Android 上的每个屏幕之间都遇到过这个问题吗?还是仅当您在智能手机上切换应用程序(并返回您的应用程序)时?

如果问题是第二个:确保MainLauncher = true在您的启动画面活动声明之前有。

例子:

[Activity(Theme = "@style/SplashTheme", MainLauncher = true, NoHistory = true, ScreenOrientation = ScreenOrientation.Portrait)]
public class SplashScreenActivity : Activity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        StartActivity(typeof(MainActivity));
    }
}

推荐阅读