开机后启动画面处理/删除

dev*_*969 5 xamarin.android xamarin

我在xamarin android应用程序中启动了启动屏幕,发生的是启动屏幕始终作为背景出现在其他页面上。

无论我做什么,都在那里。

我试图“完成”该活动,NoHistory = true,但是什么也没有,使后台的其他页面无法显示。

取自 https://alexdunn.org/2017/02/07/creating-a-splash-page-for-xamarin-forms-android/

有什么想法吗?

      [Activity(Label = "MyApp",
    Theme = "@style/MyTheme.Splash",
    Icon = "@drawable/icon", 
    MainLauncher = true, 
    NoHistory = true,
    ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.tabs;
            ToolbarResource = Resource.Layout.toolbar;

            base.OnCreate(bundle);

            Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App(new AndroidInitializer()));      

        }
    }


     [Activity(
            Theme = "@style/MyTheme.Splash",
            MainLauncher = true,
            NoHistory = true,
            ScreenOrientation = ScreenOrientation.Portrait)]
        public class SplashActivity : AppCompatActivity
        {

            public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
            {
                base.OnCreate(savedInstanceState, persistentState);

            }


          protected override void OnResume()
         {
           base.OnResume();
             var startUp = new Task(() =>
            {
             var intent = new Intent(this, typeof(MainActivity));
            StartActivity(intent);
        });
    startUp.ContinueWith(t => Finish());

    startUp.Start();
    }

      <style name="MyTheme.Splash" parent ="Theme.AppCompat.Light">
        <item name="android:windowBackground">@drawable/splash_screen</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
      </style>
Run Code Online (Sandbox Code Playgroud)

Pil*_*tus 6

这是由 引起的Theme = "@style/MyTheme.Splash"。两项活动都使用相同的主题。

为其他活动创建不同的主题。

<style name="MyTheme.Main" parent ="Theme.AppCompat.Light">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)

更改 Activity 中的主题:

[Activity(
    Theme = "@style/MyTheme.Main",
    MainLauncher = true,
    NoHistory = true,
    ScreenOrientation = ScreenOrientation.Portrait)]
public class SplashActivity : AppCompatActivity
{

    public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
    {
        base.OnCreate(savedInstanceState, persistentState);

    }
}
Run Code Online (Sandbox Code Playgroud)