diff options
3 files changed, 69 insertions, 2 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44476.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44476.cs new file mode 100644 index 00000000..1042230f --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44476.cs @@ -0,0 +1,56 @@ +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +#endif + +namespace Xamarin.Forms.Controls.Issues +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Bugzilla, 44476, "[Android] Unwanted margin at top of details page when nested in a NavigationPage")] + public class Bugzilla44476 : TestNavigationPage + { + protected override void Init() + { + BackgroundColor = Color.Maroon; + + PushAsync(new MasterDetailPage + { + Title = "Bugzilla Issue 44476", + Master = new ContentPage + { + Title = "Master", + Content = new StackLayout + { + Children = + { + new Label { Text = "Master" } + } + } + }, + Detail = new ContentPage + { + Title = "Detail", + Content = new StackLayout + { + VerticalOptions = LayoutOptions.FillAndExpand, + Children = + { + new Label { Text = "Detail Page" }, + new StackLayout + { + VerticalOptions = LayoutOptions.EndAndExpand, + Children = + { + new Label { Text = "This should be visible." } + } + } + } + } + }, + }); + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index d887d5c3..88ea2c40 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -137,6 +137,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla44338.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla45743.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla46494.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Bugzilla44476.cs" /> <Compile Include="$(MSBuildThisFileDirectory)CarouselAsync.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla34561.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla34727.cs" /> @@ -598,4 +599,4 @@ <Generator>MSBuild:UpdateDesignTimeXaml</Generator> </EmbeddedResource> </ItemGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs index ccf01f22..757a98b4 100644 --- a/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs +++ b/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs @@ -116,7 +116,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat { _detailLayout = new MasterDetailContainer(newElement, false, Context) { - TopPadding = statusBarHeight, + TopPadding = HasAncestorNavigationPage(Element) ? 0 : statusBarHeight, LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) }; @@ -263,6 +263,16 @@ namespace Xamarin.Forms.Platform.Android.AppCompat event EventHandler<VisualElementChangedEventArgs> ElementChanged; + bool HasAncestorNavigationPage(Element element) + { + if (element.Parent == null) + return false; + else if (element.Parent is NavigationPage) + return true; + else + return HasAncestorNavigationPage(element.Parent); + } + void HandleMasterPropertyChanged(object sender, PropertyChangedEventArgs e) { } |