Support libraries to add for Autosizing TextViews

Change this:

<android.support.v7.widget.AppCompatTextView
    android:autoSizeTextType="uniform"
    .../>

to this:

<TextView
    app:autoSizeTextType="uniform"
    .../>

There's no need to reference AppCompatTextView directly. The LayoutInflater used by the support library will automatically inject AppCompat widgets in place of standard widgets.

Additionally, to get auto-sizing working pre-API-26, you need to be using the support library implementation, which means you need to be using the AppCompat attributes (with the app: namespace) instead of the platform attributes (with the android: namespace).


Try changing android: to app: namespace :

<android.support.v7.widget.AppCompatTextView
    app:autoSizeTextType="uniform"
    .../>

There are contradictory answers regarding whether to use:

<android.support.v7.widget.AppCompatTextView
    app:autoSizeTextType="uniform"
    .../>

or:

<TextView
    app:autoSizeTextType="uniform"
    .../>

The difference is related to the LayoutInflater used. For example if you're using an AppCompatActivity then TextView is automatically replaced. But if you're using a FragmentActivity (which AppCompatActivity extends from), it will not, so you need to directly use AppCompatTextView to take advantage of the features.

In either case it should be app not android for pre-26 builds - but you can provide both in a single layout.

Also, you can use styles for both as well:

    <style name="TextDefault" parent="@android:style/TextAppearance.DeviceDefault">
        <item name="android:autoSizeTextType" tools:ignore="NewApi">uniform</item>
        <item name="autoSizeTextType">uniform</item>
    </style>

Note that the name does NOT include app for pre-26 builds when used in styles.