Home > Back-end >  How to insert multiple items on the same line
How to insert multiple items on the same line

Time:10-04

I wanted to ask how I could put multiple elements on the same line: label, boxview, label`

    <Grid Margin="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="2" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Label x:Name="utente" Padding="10, 0, 0, 0" Grid.Row="0" Grid.Column="0" Text="Profilo   icona" FontSize="Large" TextColor="White"></Label>
                <Label x:Name="lblClick" Padding="0, 0, 10, 0" Grid.Row="0" Grid.Column="2" Text="Logout" FontSize="Large" HorizontalOptions="End" TextColor="White">
                </Label>
                <BoxView Grid.Row="0" Grid.Column="1" Margin="0" BackgroundColor="White" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"></BoxView>
            </Grid>

enter image description here

Like this it's okay, only I would like to remove the gap between the horizontal line and the vertical line, I have already tried with the padding and with the margin, but I have not obtained results

CodePudding user response:

By default the Grid separates the objects using a Spacing value of 6

Reducing the space between objects in a grid using RowSpacing or ColumnSpacing (it will affect all the grid). Of course, one will affect space between rows and the other between columns.

In your case you want to reduce the space between the rows.

<Grid Margin="0" RowSpacing="0">
            ....Rest of your code...
        </Grid>

Happy coding!

CodePudding user response:

For the vertical white line in your picture, it is due to the use of <BoxView Grid.Row="0" Grid.Column="1" Margin="0" BackgroundColor="White" HorizontalOptions="FillAndExpand" VerticalOptions=" FillAndExpand"></BoxView>.

For the horizontal lines in your picture, it depends on the layout influence outside the Grid.

  • Related