Android Example Resizing Text Control Custom View - Set text control size based on text - Non Latin Text fix

There are many occasions when you need to have multiple labels which all size themselves to their contents and also align with each other with no space.

The solution to this is to use MeasureMultiLineText within the StringUtils Library.

To make this easy to use I created a CustomView, ResizingTextControl which you can add to a custom list view or other container and it will resize to its contents.

and made this available to the community.


However, on Android, there is a subtle problem using this which occurs with certain fonts on certain phones. MeasureMultiLineText does not appear to work correctly and calculates the wrong size and the text appears clipped.

1681905187600.png


@KZero found the solution.

It seems that non latin text may not display correctly unless you set the SetFallbackLineSpacing to False.
1681905325427.png


Doing this resolves the clipping problem.
1681905400716.png



Attached is an updated version of the Custom View which incorporates the fix.

You need Phone and Reflection to use on Android.

Selecting the FLS TRUE or FALSE will set the FallBackLineSpacing to TRUE or FALSE and you can see the difference.
 

Attachments

  • clvwithresizingtextupdated.zip
    369.8 KB · Views: 176

Soheyl

Member
Licensed User
Longtime User
There are many occasions when you need to have multiple labels which all size themselves to their contents and also align with each other with no space.

The solution to this is to use MeasureMultiLineText within the StringUtils Library.

To make this easy to use I created a CustomView, ResizingTextControl which you can add to a custom list view or other container and it will resize to its contents.

and made this available to the community.

[/URL]

However, on Android, there is a subtle problem using this which occurs with certain fonts on certain phones. MeasureMultiLineText does not appear to work correctly and calculates the wrong size and the text appears clipped.

View attachment 141328

@KZero found the solution.

It seems that non latin text may not display correctly unless you set the SetFallbackLineSpacing to False.
View attachment 141329

Doing this resolves the clipping problem.
View attachment 141330


Attached is an updated version of the Custom View which incorporates the fix.

You need Phone and Reflection to use on Android.

Selecting the FLS TRUE or FALSE will set the FallBackLineSpacing to TRUE or FALSE and you can see the difference.

Fantastic, Now it's working like a charm...
Thank you, Andrew ; )
 
Top