How to adjust text font size to fit textview

后端 未结 22 1742
無奈伤痛
無奈伤痛 2020-11-22 05:15

Is there any way in android to adjust the textsize in a textview to fit the space it occupies?

E.g. I\'m using a TableLayout and adding several Te

22条回答
  •  礼貌的吻别
    2020-11-22 06:05

    I used a variation of Dunni solution above, but that particular code didn't work for me. In particular, when trying to use the Paint object set to have the traits of the view's Paint object, and then calling measureText(), it doesn't return the same value as directly calling the view's Paint object. Perhaps there are some differences in the way my views are set up that make the behavior different.

    My solution was to directly use the view's Paint, even though there might be some performance penalties in changing the font size for the view multiple times.

提交回复
热议问题