I just wanted to ask if there is any way to justify text in a Label. I am using Xamarin Forms Xaml.
Thanks.
UPDATE:
The current way to do this is by using HorizontalTextAlignment
and the values for the TextAlignment
enumeration are:
Center
= Center-aligned textStart
= Left-alignedEnd
= Right-alignedCenter a label and its text example:
<Label x:Name="Description" HorizontalTextAlignment="Center"
VerticalOptions="Center" HorizontalOptions="Center" />
Use the XAlign
property
Label lbl = new Label();
lbl.Text = "I'm a Label!";
lbl.XAlign = TextAligntment.Start; // Start, Center, End are valid
In xaml you can use html to justify your text.
<Label LineBreakMode="WordWrap" TextType="Html" TextColor="Black">
<Label.Text><p style="text-align:justify;">
Your text here
<p></Label.Text>
Try this:
<StackLayout HorizontalOptions="FillAndExpand" Padding="0, 10, 0, 10" Spacing="0">
<Label Text="Test message" XAlign="Center"/>
<Label FontSize="Small" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." LineBreakMode="WordWrap"
XAlign="Center" />
</StackLayout>