Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how Do i make my TextView Font Size Change Dynamically depending upon the Parent View Size

I have a Text View (without a Scroll view) Inside of a Frame Layout.

The problem is that the text view shows the Text properly till it reaches the Frame Layouts size limits. What i wish to do is to Reduce the Size of the Fonts in the TextView whenever the FrameLayouts Size is Reached, so that the text can be viewed fully , as currently the text is cut after the Framelayouts size is reached.

Any inputs are welcome.

like image 575
Some one Some where Avatar asked Mar 07 '12 05:03

Some one Some where


2 Answers

If I understand you correctly, you want to shrink the text. This has been asked many times on Stack Overflow

Here are two examples of programatically shrinking the text to fit:

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

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

like image 99
Mo Kargas Avatar answered Nov 15 '22 08:11

Mo Kargas


You can use android:autoSizeTextType in API level 26. See https://stackoverflow.com/a/46798283/1162784 for more.

like image 30
arsent Avatar answered Nov 15 '22 08:11

arsent