Why don't working NoWrap of Label in xamarin.form?

110 Views Asked by At

I am trying to show full text in label. so I add Nowrap in LineBreakMode but full text don't show.

<widgets:CustomLabel ContentKey="{Binding TotalAmount, Mode=TwoWay}"
                                 Style="{StaticResource NormalLabelStyle}"
                                 TextColor="{StaticResource PrimaryBlueColor}"
                                 Margin="{StaticResource TinyMarginTop}"
                                 LineBreakMode="NoWrap"
                                 MaxLines="1"
                                 HorizontalTextAlignment="Center" />

enter image description here

Text is $0.16. if I change MaxLines to 2, here enter image description here

If I show text in one line, How should I fix it?

1

There are 1 best solutions below

0
Jessie Zhang -MSFT On

From the screenshot you shared, we can find that you want to display the string in one line, so you can set the MaxLines to 1 and set the width of the Label wide enough to wrap the string.

Of course, you can also set the HorizontalOptions to fill the width of the parent view.

For example:

    <Label x:Name="mLabel" Text="abccccccccccccc" MaxLines="1" HorizontalOptions="CenterAndExpand" />