Search code examples
xamlxamarinmonoxamarin.iosxamarin.forms

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


I have the following XAML Xamarin.Forms.Button

<Button Text="Cancel" BackgroundColor="#3079a8" TextColor="White" />

I tried to add padding to it via the Padding property but that didn't work. After checking the forums and the docs, I realised there is no padding property in the documentation for Xamarin.Forms.Button (link to the docs) , is there some other type of quick fix to add just a little bit more padding to a button? A code example would be greatly appreciated.


Solution

  • Update:

    Padding has been added to the XF Button control in Xamarin.Forms v3.2+

    <Button Padding="10,20,10,20" />
    

    Old:

    The best way to do it would be to increase the size of the button.

    Then align the text as you see fit. Unfortunately it is about the best you can do. It works well if you have your text center aligned. Not so much if its left or right aligned.