Xamarin.Forms - Screen black when using NavigationPage
I am adding a NavigationPage
in a Xamarin.Forms app. After adding the NavigationPage
, the screen was black and not showing the target page.
This is a new project, so the code is quite simple.
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new HostingPage());
}
The HostingPage
is a ContentPage
with a Label
, Entry
and Button
. I expected to see the HostingPage
, but end up seeing a black screen.
In the MainActivity
of the Android project, it was extending like this by default:
[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());
Solution 1:
Try removing Theme = "@style/MyTheme"
from MainActivity
of Android Project