Published on September 14, 2017 by Android Developers

For the best user experience with text, material design recommends using a dynamic type instead of smaller type sizes or truncating larger-size text. With Android O and Support Lib 26, TextView gains a new property: autoSizeTextType, which allows the text to scale uniformly when working with dynamic content. You can fine tune the auto-size by setting the minimum and maximum values and the step granularity, or by using preset text sizes.

For more info check out these links!
Autosizing TextViews guide: goo.gl/JZ85Ap
Google I/O 2017 talk on “What’s new in Support Library”: goo.gl/Ukf4Mz

Subscribe to the Android Developers channel here: goo.gl/vLYDU

Leave a Reply

72 Comments on "TextView: Now with Auto-Sizing"

Notify of
avatar

Alexander Morbid
Guest
Alexander Morbid
5 months 2 days ago

For some reason, while trying to use support library in XML file, Android Studio keeps nagging at me with error, suggesting to add "android:" prefix instead of "app:" in the line app:autoSizeTextType="uniform".
Of course changing it to "android:" generates warning that minimum supported API should be 26.
DUH, I know, genius. That's why I'm trying to use support library in the first place.

Nevertheless, adding tools:ignore="MissingPrefix" shuts this bloody thing up and everything works.
I still don't know what's up with that though…

Brent Allen
Guest
Brent Allen
5 months 28 days ago

Thanks this helps a ton! Figured there had to be an easy way. Clear and informative.

Olaf Gottschalk
Guest
Olaf Gottschalk
6 months 11 days ago

I wish I could supply a specific text which is only used to determine the text size to make it fit into the view, even though I currently display a shorter text… Why? Because I have fields that are counting. And I want the text size to adopt to the largest value that will eventually be displayed there…

Ruell Brown
Guest
Ruell Brown
6 months 23 days ago

I'm having an issue where I have an autosizing textview next to an imageview (down arrow)…. we want the arrow to be next to the textview no matter what size the text is. But on longer values it's covering up the arrow.

Gangadhar S Lahane
Guest
Gangadhar S Lahane
7 months 1 day ago

what was the previous approach to achieve text view autosizing?

Reyansh Mishra
Guest
Reyansh Mishra
7 months 6 days ago

It has performance issue when used in recycler view as it calculates the sizes for every item, isn't it?

Pero Peric
Guest
Pero Peric
9 months 14 days ago

Be my wife! 🙂

Pero Peric
Guest
Pero Peric
9 months 14 days ago

Be my wife! 🙂

fgcncn gbbnfgb
Guest
fgcncn gbbnfgb
9 months 19 days ago

есть такие видео с переводом на русский

fgcncn gbbnfgb
Guest
fgcncn gbbnfgb
9 months 19 days ago

есть такие видео с переводом на русский

1 2 3 6
wpDiscuz