strange space between buttons in Xamarin

1k views Asked by At

I'm working in a small piece of UI in Xamarin just a "card" with some labels and two buttons in the right side as a column. Here you can see my Xaml:

<Grid BackgroundColor="White" RowSpacing="0" ColumnSpacing="0" Margin="10,10,10,0">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="80"/>
    </Grid.ColumnDefinitions>

    <StackLayout Grid.Column="1" 
                 Spacing="0" 
                 BackgroundColor="PaleGoldenrod">
        <Button Text="OPEN" Margin="0" 
                VerticalOptions="FillAndExpand" 
                HeightRequest="70"/>
        <Button Text="RESET" Margin="0" 
                VerticalOptions="FillAndExpand" 
                HeightRequest="70"/>
    </StackLayout>

    <Label TextColor="Black" Margin="5">Relojes</Label>
    <Label  HorizontalTextAlignment="End" 
            TextColor="Black" 
            Margin="5">Sin Tocar</Label>
</grid>

And here you can see a picture of what I've got:

enter image description here

I want to remove the space between the two buttons so they are evenly spaced all around. I tried setting the bottom margin in the upper button as -2.5 and the upper margin of the bottom button as -2.5 and looks Ok but .. There must be a cleaner option. Any idea ??

1

There are 1 answers

7
Arvind Chourasiya On

Use Spacing in StackLayout to reduce space between controls. Here Spacing in minus.

<StackLayout  Grid.Column="1" 
Spacing="-8" 
BackgroundColor="PaleGoldenrod">
<Button Text="OPEN" Margin="0" 
VerticalOptions="FillAndExpand" 
HeightRequest="70"/>
<Button Text="RESET" Margin="0" 
VerticalOptions="FillAndExpand" 
HeightRequest="70"/>
</StackLayout>

enter image description here