(Android)在Xamarin Forms 3.3上更改模块时始终显示启动画面吗?

时间:2019-01-07 14:15:27

标签: android xamarin xamarin.forms xamarin.android splash-screen

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

switch module

Splash Screen

Xamarin Forms 2.5版上,没有此问题。

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

我尝试过,但是不起作用。 ANDROID: SPLASH: Why I always see splash screen when app is resumed

这是我的代码:

  <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>

并在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)]

请帮助我!

谢谢!

1 个答案:

答案 0 :(得分:0)

您在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));
    }
}