Bug 44476 - [Android] Unwanted margin at top of details page when nested in a NavigationPage
Summary: [Android] Unwanted margin at top of details page when nested in a NavigationPage
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.2
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-09-19 06:53 UTC by Ryan Dixon
Modified: 2017-01-19 13:43 UTC (History)
9 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:

Bug has not been fixed (36.16 KB, image/png)
2017-01-19 13:43 UTC, Joaquín Cuitiño

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Ryan Dixon 2016-09-19 06:53:50 UTC
Reproduction Steps:
1) Make a new PCL project using Xamarin Forms 2.3.2 with Android Support Libraries all version 23.3.0
2) Construct a new NavigationPage with a background colour using a MasterDetailPage as the passed parameter to the constructor
3) Set a new ContentPage for the MDP Details with a solid background color

Expected Results:
Details ContentPage will fill the screen across all platforms

Actual Results:
Margin at the of page on Android Platform which cannot be removed

Devices Tested:
Nexus 7 (2013) - Android 6.0
Samsung S6 Edge - Android 6.0

Forum Post Link (w Images)
Comment 1 hiraldesai 2016-10-18 17:23:38 UTC
Is there an ETA to this fix?
Comment 2 adrianknight89 2016-10-19 16:17:38 UTC
I can work on this since I've had to work on crap like status bar, adjust mode, and fullscreen on AppCompat. The problem is XF's implementation of MasterDetailPage is somewhat hacky. In order to show master behind the status bar, padding is applied on the detail page. So that void you're seeing should be the same size as the status bar height. MDP needs to account for the presence of a parent.

This PR is sitting in the queue: https://github.com/xamarin/Xamarin.Forms/pull/422

Although it addresses another issue, it should go hand-in-hand with the fix for this.
Comment 3 adrianknight89 2016-10-19 16:22:02 UTC
Having said that, I think it's weird to nest an MDP inside a navigation page. People do the same with a TabbedPage. Does the MDP even give you the back arrow when nested inside a navigation page? On Android, you can hit the back button, but iOS lacks one.
Comment 4 hiraldesai 2016-10-19 17:34:17 UTC
Thanks for the update. I have had the exact same thought about this, but I'm pretty sure not having the MDP inside NavigationPage causes errors when trying to navigate from the root of the MDP to any other content page (especially when your MDP is the MainPage of the app).
Comment 5 adrianknight89 2016-10-19 18:36:29 UTC
Ideally, you should avoid setting MainPage twice. If your MainPage is an MDP, stick to it. Use detail pages as navigation or content pages. If you have a need to navigate away from the MDP to something else, consider pushing them modally (i.e. still keep the MDP as MainPage).
Comment 6 adrianknight89 2016-10-19 18:39:29 UTC
Perhaps the other way around can also be valid. Use NavigationPage as MainPage and push MDP modally (I've never tried this). In either case, nesting one inside the other can cause issues.
Comment 7 hiraldesai 2016-10-19 18:57:49 UTC
I'm setting MainPage once only like this.

These are application level variables in app.xaml.cs

public static RootPage Root { get; set; }
public static INavigation RootNavigation => Root.Detail.Navigation;
public static MasterPage Master => (MasterPage) Root.Master;

And this is the starting point of the app

public App()
var rootPage = new RootPage();
var mainPage = new NavigationPage(rootPage);
Root = rootPage;				
MainPage = mainPage;								

Each of the possible detail pages in the MDP is a NavigationPage with its own navigation stack. So you can get to parent level master from the menu but have to do some interaction on the parent to see the inner navigation or modal pages. 

So most of my navigation is either:


await App.RootNavigation.PushAsync(new Level2ChildContentPage(), true);

The child content pages then either navigate users a level deeper using the similar code above or just reset the root's master like this (not sure if that's the right way of doing it)

App.Root.Detail = new NavigationPage(new Level1ParentContentPage());

Or 2)

await App.RootNavigation.PushModalAsync(new NavigationPage(new ContentPage()), true);

The modal navigation pages have a toolbar with a close button (not shown above) that just pops the modal from App.RootNavigation.
Comment 8 Paul DiPietro [MSFT] 2016-10-19 21:11:55 UTC
I put up a PR for this earlier. The padding is the height of the status bar being applied to the detail page.
Comment 9 Samantha Houts [MSFT] 2016-12-08 00:28:28 UTC
Should be fixed in 2.3.4-pre1. Thank you!
Comment 10 Joaquín Cuitiño 2017-01-19 13:43:42 UTC
Created attachment 19396 [details]
Bug has not been fixed

Not fixed, the margin is still there for the master.