Home > OS >  Xamarin Line Break in label for long words in german
Xamarin Line Break in label for long words in german

Time:04-21

I´m developing an app in xamarin and I have the next scenario.

I have a label with maxLines = 3, for some long words in german or french the line break doesn't separate the words syllabels correctly, for example the correct separation of the word "Bezirksschornsteinfegermeister" is "Bezirkss–chorn–ste–in–fegermeis–ter" but in the app is showing like this

enter image description here

It should be Bezirksschorn(First Line) steinfegermeister(Second Line)

This is my code

<Label
Margin="24,0,24,14"
FontSize="18"
HorizontalTextAlignment="Center"
LineBreakMode="TailTruncation"
MaxLines="3"
Text="Bezirksschornsteinfegermeister"
VerticalTextAlignment="End" />

The line break for long words works fine for english words but not for german or french words. There is any library that make a correct line break separation for german and french?

CodePudding user response:

This isn't a Xamarin issue, if you are testing on Android then German language is not supported, only English, check this issue. Not sure about the iOS.

CodePudding user response:

If you go through the options for LineBreakMode in the official docs as below:

  • HeadTruncation – truncates the head of the text, showing the end.

  • CharacterWrap – wraps text onto a new line at a character boundary.

  • MiddleTruncation – displays the beginning and end of the text, with the middle replace by an ellipsis.

  • NoWrap – does not wrap text, displaying only as much text as can fit on one line.

  • TailTruncation – shows the beginning of the text, truncating the end. WordWrap – wraps text at the word boundary.

Obviously,we can't divide a long string into separate words.You may need add spacing or other characters to separate words.

  • Related