How to get N text that can be fit on Screen/TextView with a specific size?

前端 未结 3 1706
耶瑟儿~
耶瑟儿~ 2021-02-04 14:42

I have a large story in String format. I want to show the text in gallery. What I want to do is to slice all the text in such a way that all my view in gallery show the text whi

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-04 14:51

    Graphics.getFontMetrics and FontMetrics.stringWidth will help you to determine real size of text on the screen. Based on this calculation you can determine how long shown substring should be.

提交回复
热议问题