【发布时间】:2018-04-21 04:26:50
【问题描述】:
我在我的 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>
【问题讨论】:
标签: xamarin xamarin.android splash-screen