cedd
cedd

Reputation: 1861

Make Xamarin button the size of its text but no bigger

I create the following button in a Xamarin Portable Class Library app

Content = new Button { Text = "Up", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center,  MinimumWidthRequest = 0, MinimumHeightRequest = 0 };

This give me a button that looks like this

Xamarin button that its bigger than its text

I want one that looks more like this

Button that is sized to its text

This is quite easy to do in native Android layouts (RelativeLayout and LinearLayout etc).

I have tried a million things but I can't get it to happen in Xamarin, does anyone know how to do it?

Upvotes: 4

Views: 3236

Answers (1)

MStew
MStew

Reputation: 1275

What you are looking for is a way to set the Padding property on the button, which is not available in Forms. Here's a link to a Xamarin forums post where someone had a question similar to yours and the answer, as of now, is to create a custom renderer.

Upvotes: 1

Related Questions