Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android autosizing TextViews split up words before decreasing font size

Is there a way to avoid it?

If my text is "Blablabla" and it doesn't fit in a square, I don't want to have something like:

Blabla- bla

I want "Blablabla" with a smaller font size. Is there a way to control whether the autosizing TextView will split up words or not?

Here's an example of the issue:

enter image description here

The minimum text size there is 1sp, so it's pretty clear the word could fit with a decreased text size.

It seems this has been reported: https://issuetracker.google.com/issues/38468964

like image 939
Fred Porciúncula Avatar asked Oct 27 '17 13:10

Fred Porciúncula


People also ask

What is autoSizeStepGranularity?

autoSizeMaxTextSize is the maximum size of textview it will take autoSizeMinTextSize is the minimum size of textview it will take and autoSizeStepGranularity is the size of each step.

How do you get 3 dots at the end of a TextView text?

You are applying to your TextView a compound Drawable on the right.. to make the three dots appear in this scenario, you have to apply a android:drawablePadding="{something}dp" attribute to the TextView as well. Hope it helps!

Which attribute increases or decreases the font size of TextView?

How do I Auto Resize TextView? To use preset sizes to set up the autosizing of TextView in XML, use the android namespace and set the following attributes: Set the autoSizeText attribute to either none or uniform. Set the autoSizePresetSizes attribute to an array of preset sizes.


1 Answers

I came here having the same issues with two-line text as others. The only thing that works for me is this: https://github.com/AndroidDeveloperLB/AutoFitTextView

It's not as convenient as adding a couple lines to your layout, but it works in situations where Android's auto size doesn't.

like image 52
Eric B. Avatar answered Oct 09 '22 06:10

Eric B.