xamarin/Xamarin.Forms

Setting width of master page is not working for tablet.

開放

#8,909 建立於 2019年12月16日

 (5 則留言) (1 個反應) (0 位負責人)C# (1,926 個分叉)batch import
e/4 :clock4:help wantedinactivep/Androidp/tablett/bug :bug:up-for-grabs

倉庫指標

星標
 (5,644 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Description

I am trying to change width of master page in landscape mode for tablet. I have used renderer for that. Using that i am able to change the master page width in mobile phone. But it is not working for tablet.

Steps to Reproduce

  1. Create one xamarin forms project in Master-Detail template. 2.Create MasterDetailPagePCL class fro renderer.

    public class MasterDetailPagePCL : MasterDetailPage { public static readonly BindableProperty DrawerWidthProperty = BindableProperty.Create("DrawerWidth", typeof(float), typeof(MasterDetailPagePCL), 0.1f, BindingMode.TwoWay, null);

     public float DrawerWidth
     {
         get { return (float)GetValue(DrawerWidthProperty); }
         set { SetValue(DrawerWidthProperty, value); }
     }
    

    }

  2. In Android project I have added this renderer.

public class MasterDetailAndroidRenderer : MasterDetailRenderer { public MasterDetailAndroidRenderer(Context context) : base(context) {

    }

    public override void AddView(Android.Views.View child)
    {
       
        MasterDetailPagePCL page = (MasterDetailPagePCL)this.Element;
        LayoutParams p = (LayoutParams)child.LayoutParameters;

        p.Width = 160;

        base.AddView(child,p);
    }
}

4. Deploy this project in tablet. 5. Rotate tablet to landscape mode.

Expected Behavior

  1. It's master page should get fixed(Which is working fine).
  2. Width of master page should get changed as per the "DrawerWidth" peoperty.

Actual Behavior

  1. Width of master page not changing as per the "DrawerWidth" peoperty.

Basic Information

Xamarin Forms version: 4.4.0.991265

  • IDE:
  • Platform Target Frameworks:
    • Android:
  • Android Support Library Version:
  • Nuget Packages:4.4.0.991265
  • Affected Devices:honor tablet(Android 7.0 MasterPageWidthBug )

Screenshots

Reproduction Link

貢獻者指南