【问题标题】:Xamarin.Forms - Screen black when using NavigationPageXamarin.Forms - 使用 NavigationPage 时屏幕变黑
【发布时间】:2016-08-09 01:40:12
【问题描述】:

我在 Xamarin.Forms 应用程序中添加 NavigationPage。添加NavigationPage后,黑屏,不显示目标页面。

这是一个新项目,所以代码很简单。

public partial class App : Application
{
    public App()
    {
        InitializeComponent();
        MainPage = new NavigationPage(new HostingPage());
    }

HostingPage 是一个 ContentPageLabelEntryButton。我原以为会看到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());

【问题讨论】:

    标签: android xamarin navigation xamarin.forms


    【解决方案1】:

    尝试从 Android 项目的 MainActivity 中删除 Theme = "@style/MyTheme"

    【讨论】:

      【解决方案2】:

      global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity 替换为 Activity 并从中删除 Theme = "@style/MyTheme" Activity 的属性。

      【讨论】:

        【解决方案3】:
        public partial class App : Application
        {
            public App()
            {
                InitializeComponent();
                MainPage = new NavigationPage(new HostingPage());
            }
        }
        

        你必须这样做:

        MainPage = new new HostingPage();
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-11-15
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多