Forum Xamarin.Forms

How do you allow buttons to maximize the space inside it for text?

CRoscoeCRoscoe CAMember ✭✭

As I currently have it, I wrote a bit of code that allows you to get the font size needed for text (label or button) to fit exactly into the encompassing area.

The problem I'm having though is it seems buttons have a built in padding that I cannot change, and I was wondering if anyone knows of a way to fix it?

Here is a quick screenshot of the tabs of buttons at the top of my app. I copied it and pasted it underneath and eddited the first button just to show how much room is still left over, and how despite all that extra room my button is choosing to wrap instead of just displaying the text in one row.

Any idea how to do this? Buttons don't have a padding/spacing/margin property, and the stack layout that encompasses it has it's spacing set to 0.

Best Answers


  • hvaughanhvaughan USMember ✭✭✭
    edited April 2017

    For iOS, you would add the following into the custom renderer:
    Control.ContentEdgeInsets = new UIEdgeInsets((int)view.Padding.Left, (int)view.Padding.Top, (int)view.Padding.Right, (int)view.Padding.Bottom);

Sign In or Register to comment.