Sunday 25 October 2020

How to fit text into StaticLayout with fixed width and height in Android?

I'm trying to draw text using Canvas and have found that using StaticLayout would take care of the line breaks automatically. I also want to limit its height so that when text is too long it would be ellipsized, but the size of text container is dynamic. I can easily apply the width to StaticLayout, but cant find a way to do height.

I tried to utilize TextUtils.ellipsize(), but having issue to get the spacing between lines.



from How to fit text into StaticLayout with fixed width and height in Android?

No comments:

Post a Comment