[Android] Take in account status bar padding on master when using split behaviour...
authorRui Marinho <me@ruimarinho.net>
Fri, 17 Jun 2016 18:55:06 +0000 (19:55 +0100)
committerJason Smith <jason.smith@xamarin.com>
Fri, 17 Jun 2016 18:55:06 +0000 (11:55 -0700)
Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs
Xamarin.Forms.Platform.Android/Renderers/MasterDetailContainer.cs

index 1815321..50e99e5 100644 (file)
@@ -122,6 +122,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
 
                                        _masterLayout = new MasterDetailContainer(newElement, true, Context)
                                        {
+                                               TopPadding = ((IMasterDetailPageController)newElement).ShouldShowSplitMode ? statusBarHeight : 0,
                                                LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Gravity = (int)GravityFlags.Start }
                                        };
 
index 9184e26..7e28392 100644 (file)
@@ -120,6 +120,7 @@ namespace Xamarin.Forms.Platform.Android
                        double width = Context.FromPixels(right - left);
                        double height = Context.FromPixels(bottom - top);
                        double xPos = 0;
+                       bool supressPadding = false;
 
                        //splitview
                        if (MasterDetailPageController.ShouldShowSplitMode)
@@ -131,11 +132,13 @@ namespace Xamarin.Forms.Platform.Android
                        }
                        else
                        {
+                               //if we are showing the normal popover master doesn't have padding
+                               supressPadding = isMasterPage;
                                //popover make the master smaller
                                width = isMasterPage && (Device.Info.CurrentOrientation.IsLandscape() || Device.Idiom == TargetIdiom.Tablet) ? DefaultWidthMaster : width;
                        }
 
-                       double padding = Context.FromPixels(TopPadding);
+                       double padding = supressPadding ? 0 : Context.FromPixels(TopPadding);
                        return new Rectangle(xPos, padding, width, height - padding);
                }