Xamarin表单-Android Splashscreen也显示在主应用程序中
我已经在我的应用程序中添加了一个splashscreenXamarin表单-Android Splashscreen也显示在主应用程序中,android,xamarin.forms,xamarin.android,splash-screen,Android,Xamarin.forms,Xamarin.android,Splash Screen,我已经在我的应用程序中添加了一个splashscreen <item name="android:windowBackground">@drawable/splashScreen</item> @可拖动/飞溅屏幕 到我的应用程序的main主题 splashscreen在应用程序启动时正确显示,但在应用程序的所有页面中保持为backgound 我怎样才能避免这种行为 一个更好地展示行为的视频 谢谢大家! 您至少需要有两个主题。一个用于启动屏幕,另一个用于应用程序的其余部
<item name="android:windowBackground">@drawable/splashScreen</item>
@可拖动/飞溅屏幕
到我的应用程序的main主题
splashscreen在应用程序启动时正确显示,但在应用程序的所有页面中保持为backgound
我怎样才能避免这种行为
一个更好地展示行为的视频
谢谢大家! 您至少需要有两个主题。一个用于启动屏幕,另一个用于应用程序的其余部分(您也可以为特定页面设置其他主题) 在我的例子中,我用“splashscreen”作为启动屏幕,用“AppTheme”作为应用程序的其余部分 将启动主题定义为:
<style name="splashscreen" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/Zenon_Welcome_Screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowIsFloating">false</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
现在,在onCreate方法中,您需要切换主题,如下所示:
/// <summary>
/// On create.
/// </summary>
/// <param name="bundle">Bundle.</param>
protected override void OnCreate(Bundle bundle)
{
base.Window.RequestFeature(WindowFeatures.ActionBar);
// Name of the MainActivity theme we want to use for the app.
// Or we can use global::Android.Resource.Style.ThemeHoloLight / Theme Name.
base.SetTheme(Resource.Style.AppTheme);
base.OnCreate(bundle);
}
//
///关于创建。
///
///捆。
创建时受保护的覆盖无效(捆绑包)
{
base.Window.RequestFeature(WindowFeatures.ActionBar);
//要用于应用程序的主活动主题的名称。
//或者我们可以使用global::Android.Resource.Style.ThemeHollight/主题名。
SetTheme(Resource.Style.AppTheme);
base.OnCreate(bundle);
}
[Activity(Label = "AppName", Icon = "@drawable/icon", Theme = "@style/splashscreen", MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, ScreenOrientation = ScreenOrientation.Portrait,
LaunchMode = LaunchMode.SingleTask)]
public class MainActivity : FormsAppCompatActivity
/// <summary>
/// On create.
/// </summary>
/// <param name="bundle">Bundle.</param>
protected override void OnCreate(Bundle bundle)
{
base.Window.RequestFeature(WindowFeatures.ActionBar);
// Name of the MainActivity theme we want to use for the app.
// Or we can use global::Android.Resource.Style.ThemeHoloLight / Theme Name.
base.SetTheme(Resource.Style.AppTheme);
base.OnCreate(bundle);
}