question

Hoobie-2996 avatar image
0 Votes"
Hoobie-2996 asked ColeXia-MSFT published

How to Center 2 labels on 1 grid row

Hi,
I want to center 2 labels (first one is an icon, second one is a data field) on 1 single row. Could anyone please advice how to achieve this so the icon + the data is horizontal centered on the phone
I added a code snippet from my existing code
88344-codesnippet.png



Could someone please give me some guidance or small example , thanks a lot

Kris

dotnet-xamarin
codesnippet.png (42.6 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ColeXia-MSFT avatar image
0 Votes"
ColeXia-MSFT answered ColeXia-MSFT published

Hello,

Welcome to Microsoft Q&A!

Set VerticalTextAlignment="End" on the first label .

Set VerticalTextAlignment="Center" on the second label .

My test

88424-capture.png


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



capture.png (17.5 KiB)
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,

Probably I was not very clear in my explanation, sorry for that.
I included a screenshot of the result I would like to have, hope that will make things clear.
88535-visualexample.png


1 Vote 1 ·
visualexample.png (23.6 KiB)

Sorry , I misunderstood .

You can place the two label into StackLayout , and set its HorizontalOptions as Center .


<StackLayout Orientation="Horizontal" BackgroundColor="Red" HorizontalOptions="Center" Grid.ColumnSpan="2">
            <Label Text="&#xf2b9;"  FontAttributes="Bold" FontSize="20" VerticalTextAlignment="End"  HorizontalTextAlignment="End" FontFamily="a"/>
            <Label Text="djiaiadhh" VerticalTextAlignment="Center" FontSize="20"  HorizontalTextAlignment="Start" />
        </StackLayout>


88518-capture.png


2 Votes 2 ·
capture.png (22.2 KiB)

Great! Thanks a lot that really helped me out, but actually it was too easy for not seeing this myself...

0 Votes 0 ·
Show more comments