How to auto size textview dynamically according to the length of the text in android?

前端 未结 7 793
不思量自难忘°
不思量自难忘° 2021-02-04 07:07

I am taking data of variable sizes from the server and setting to a textView and i wanted the textview to resize according to the length of the text set.

It is given in

7条回答
  •  不知归路
    2021-02-04 07:28

    Bear in mind that this does break accessibility. For example, if user decides to change font size through phone settings, because he simply cannot see very well, autosized text views with height set as DP won't be impacted.

    In order to work around this, you should use android:layout_height with SP, so that it would also be scaled, when accessibility settings were changed.

提交回复
热议问题