Skip to content

Most visited

Recently visited


Autosizing TextViews

Android O allows you to instruct a TextView to let the size of the text expand or contract automatically to fill its layout based on the TextView's characteristics and boundaries. This setting makes it easier to optimize the text size on different screens with dynamic content.

Setting up TextView autosize

You can set up the TextView autosizing in either code or XML. There are two ways you can set it up:


By using granularity, you can specify a range of minimum and maximum text sizes and a dimension that specifies the size of each step. The TextView can uniformly scale, in a range between the given minimum and maximum size attributes. Each increment takes on the step size specified in the granularity attribute.

To set up the autosizing by using granularity, do either of the following:

Preset Sizes

By using preset sizes, you can autosize the TextView from a list of predefined sizes.

To set up the autosizing by using preset sizes, do either of the following:

This site uses cookies to store your preferences for site-specific language and display options.


This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.