Xamarin Forms: How can I add padding to a button?

前端 未结 6 1152
天涯浪人
天涯浪人 2021-02-01 19:30

I have the following XAML Xamarin.Forms.Button

I tried to add

6条回答
  •  没有蜡笔的小新
    2021-02-01 19:58

    It doesn't work for me in android. Looking at SetPadding function, I see that the Control has a minimum height of 132 and a minimum width of 242. I changed the SetPadding function in:

     private void SetPadding()
        {
            var element = Element as ExtendedButton;
            if (element != null)
            {
                Control.SetMinHeight(-1);
                Control.SetMinimumHeight(-1);
                Control.SetMinWidth(-1);
                Control.SetMinimumWidth(-1);
                Control.SetPadding(
                    (int)element.Padding.Left,
                    (int)element.Padding.Top - 6,
                    (int)element.Padding.Right,
                    (int)element.Padding.Bottom - 6);
            }
        }
    

提交回复
热议问题