TextView autoSizeTextType is not detecting in xml

后端 未结 3 1644
半阙折子戏
半阙折子戏 2021-01-05 17:40

I\'m looking for changing the TextView Sizes automatically. And I found the solution as well. Here is the official Doc for Auto sizing textviews. But Still

相关标签:
3条回答
  • 2021-01-05 18:11

    This API is available only from API level 26.

    0 讨论(0)
  • 2021-01-05 18:16

    Use AppCompatTextView and supportLibrary 26.0.1

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <android.support.v7.widget.AppCompatTextView
           android:layout_width="match_parent"
           android:layout_height="200dp"
           app:autoSizeTextType="uniform" />
    
    </LinearLayout>
    
    0 讨论(0)
  • 2021-01-05 18:36

    As stated in the docs:

    The Support Library 26.0 provides full support to the autosizing TextView feature on devices running Android versions prior to Android 8.0 (API level 26). The library provides support to Android 4.0 (API level 14) and higher. The android.support.v4.widget package contains the TextViewCompat class to access features in a backward-compatible fashion.

    You need to replace TextView with AppCompatTextView and upgrade your support lib to v26.0.0 in order to use that feature.

    compile 'com.android.support:support-v4:26.0.0'
    

    Don't forget to upgrade your buildToolsVersion to 26.0.0 and compileSdkVersion to 26 as well.

    0 讨论(0)
提交回复
热议问题