Reputation: 1530
Has anyone figured out how to center (or justify or in any way horizontally effect) text in a Xamarin Forms Label with LineBreakMode=WordWrap
? Without using a WebView (or similar)?
All HorizontalOptions
entries are cheerfully ignored in this code snippet:
<StackLayout>
<Label
Margin="75,0,75,0"
FontAttributes="Italic"
FontSize="Large"
HorizontalOptions="Center"
LineBreakMode="WordWrap"
Text="Live life as though nobody is watching, and express yourself as though everyone Is listening."
VerticalOptions="CenterAndExpand" />
</StackLayout>
It looks like this.
Upvotes: 3
Views: 2556
Reputation: 588
add this line in your code
HorizontalTextAlignment="Center"
<StackLayout>
<Label
Margin="75,0,75,0"
FontAttributes="Italic"
FontSize="Large"
HorizontalOptions="Center"
HorizontalTextAlignment="Center"
LineBreakMode="WordWrap"
Text="Live life as though nobody is watching, and express yourself as though everyone Is listening."
VerticalOptions="CenterAndExpand" />
</StackLayout>
Upvotes: 0
Reputation: 1507
You should use HorizontalTextAlignment="Center" in this case.
<StackLayout>
<Label
Margin="75,0,75,0"
FontAttributes="Italic"
FontSize="Large"
HorizontalOptions="Center"
HorizontalTextAlignment="Center"
LineBreakMode="WordWrap"
Text="Live life as though nobody is watching, and express yourself as though everyone Is listening."
VerticalOptions="CenterAndExpand" />
</StackLayout>
Upvotes: 5