Google now provide a way of having TextViews increase or decrease their text size to fill the available space.
No longer do you have to turn to 3rd party solutions to fill this fairly common design requirement.
As of Android Oreo, and Support Library 26.0.1, you can specify that any TextView should autosize. Because it is provided in the Support Library, you can use this feature today on devices all the way back to Ice Cream Sandwich.
This lesson provides an introduction into using Autosizing TextViews.
You'll learn how enable this feature for your TextViews. We'll start with a sample app containing regular (non-resizing) TextViews, and configure them to resize to fill their available space.
We'll show how to do this both in XML and how to do it programmatically, in Java code.
- Which Support Library version is required
- How to add Support Library to project
- How to configure a TextView to scale its text uniformly, to fill the available space
- In XML
- In Java
- How to workaround a known bug in the tooling
- Limitations of Autosizing TextView feature