简体   繁体   English

Xamarin表单MasterDetailPage MasterBounds

[英]Xamarin Forms MasterDetailPage MasterBounds

can someone tell me how to edit the value for MasterBounds in XF-MasterDetailPage. 有人可以告诉我如何在XF-MasterDetailPage中编辑MasterBounds的值。 My changes have no effect (MasterDetailPageRenderer/Android): 我的更改无效(MasterDetailPageRenderer / Android):

protected override void OnLayout(bool changed, int l, int t, int r, int b)
{
  base.OnLayout(changed, l, t, r, b);
  if (page != null && page.MasterBehavior == MasterBehavior.Split)
  {
    if (((IMasterDetailPageController)page).MasterBounds.Y > 0)
    {
      Rectangle rect = ((IMasterDetailPageController)page).MasterBounds;
      rect.Y = 0;
      ((IMasterDetailPageController)page).MasterBounds = rect;
    }
  }
}

I need to do this, because the value for Y is wrong on some Devices, so there is a bit of space at the top. 我需要这样做,因为在某些设备上Y的值是错误的,因此顶部有一些空间。

Thanks! 谢谢!

In case someone else needs this, here is the solution: 如果其他人需要这个,这里是解决方案:

public override void AddView(Android.Views.View child)
{
  child.GetType()?.GetProperty("TopPadding")?.SetValue(child, 0);
  base.AddView(child);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM