我在Xamarin.Forms应用中添加了NavigationPage
。添加NavigationPage
后,屏幕显示为黑色,未显示目标页面。
这是一个新项目,因此代码非常简单。
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new HostingPage());
}
HostingPage
是ContentPage
,Label
,Entry
和Button
。我希望看到HostingPage
,但最终会看到黑屏。
在Android项目的MainActivity
中,默认情况下它是这样扩展的:
[Activity(Label = "Meeting.Droid", Icon = "@drawable/icon", Theme = "@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
答案 0 :(得分:1)
尝试从Android项目的Theme = "@style/MyTheme"
中删除MainActivity
答案 1 :(得分:0)
通过活动替换 global :: Xamarin.Forms.Platform.Android.FormsAppCompatActivity ,并从中移除 Theme =“@ style / MyTheme”活动的属性。