Andrestar
Andrestar

Reputation: 11

how to change the margin of a button on xamarin forms?

i have a issues with default margin of a button on xamarin forms. i need to take off the margin. some thought how i can make this ?? i need to use custom renderer?

I really need this to join two elements without leaving space, a label and a button.

i already try with

<Button
    BackgroundColor="Fuchsia"
    BorderRadius="0"
    BorderWidth="0"
    Text="Test"
    HeightRequest="50"
    WidthRequest="60"
    TextColor="#333333"
    x:Name="btnBack"
    Margin="0"
    VerticalOptions="Start"
    HorizontalOptions="Start" />

but this not work for me, nothing happened. other guys says that making a custom renderer maybe will work.

Upvotes: 1

Views: 2626

Answers (2)

Jeff Jose
Jeff Jose

Reputation: 131

If you want to change margins dynamically, you would write something like this in C#

button.margin = new thickness(0,0,0,0);

This would make the margins of the button 0.

You would potentially do this for all elements with a thickness to change that issue.

Upvotes: 1

Steve Chadbourne
Steve Chadbourne

Reputation: 6953

What are you using to lay out the label and the button? If StackLayout you may need to set the StackLayout Spacing property to 0 to remove the gap between the label and the button. If Grid look at RowSpacing and ColumnSpacing properties.

Upvotes: 2

Related Questions