How can I change the font size of a TextView dynamically depending on the size of the parent view

I have a text view (without scroll view) Inside the frame layout.

The problem is that the text view correctly displays the text until it reaches the size limits of the frame layout. I want to reduce the font size in the TextView whenever FrameLayouts are reached so that the text can be viewed completely, since the text is currently cut after reaching the Framelayouts size.

Any inputs are welcome.

+4
source share
2 answers

If you understand correctly, you want to reduce the text. This has been set repeatedly in Stack Overflow.

Here are two examples of programmatic text reduction:

http://jeffreysambells.com/posts/2010/04/04/android-textview-with-auto-sized-content/

http://catchthecows.com/?p=72

+5
source

You can use android:autoSizeTextType in API level 26. For more details see fooobar.com/questions/12431 / ....

+2
source

Source: https://habr.com/ru/post/1400149/


All Articles