简体   繁体   中英

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM