-1

How to justify the Binding Text ?

My code is shown below but it didn't help me

<StackLayout  HorizontalOptions="Fill" Padding="20,20,20,20" Spacing="2">
    <Label Text="{Binding MainText}" HorizontalOptions="Fill" 
           VerticalOptions="Center" XAlign="Start" LineBreakMode="WordWrap" 
           x:Name="aboutUs" TextColor="Black"/>
</StackLayout>
Stephane Delcroix
  • 16,134
  • 5
  • 57
  • 85
Adit Kothari
  • 63
  • 1
  • 10
  • [See this reply](https://stackoverflow.com/questions/30062368/xamarin-forms-label-justify/53945760#53945760), easily done with platform renderer. – Maxim Saplin Dec 27 '18 at 13:22

1 Answers1

1

Short answer: Xamarin.Forms doesn't gives you a way to do it directly.

Longer answer: The only valid values for HorizontalTextAlignment (which you should use instead of the deprecated XAlign) are Start, Center and End and doesn't provide any way to justify the text. So you can't justify a label.

If you really want to have justified text, you could:

  • implement your own LabelRenderer that supports it;
  • or, simpler, as it's an About Us box, use a WebView and rely on the HTML engine to justify the text for you.
Stephane Delcroix
  • 16,134
  • 5
  • 57
  • 85