TextView autoSizeTextType not working in application

I tried to use autoSizeTextType. My minSdk is 24, all tools are 26 and compat ist 26-beta2.

The ability to configure them was tested using the code:

dialogWeight.touchables.filterIsInstance<Button>().forEach {
TextViewCompat.setAutoSizeTextTypeWithDefaults(it, 
TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM) }

And xml:

<android.support.v7.widget.AppCompatTextView
android:layout_height="match_parent"
android:text="7"
android:autoSizeTextType="uniform"/>

Any ideas? I'm starting to believe that he is being tapped

+4
source share
2 answers

Ok, so a combination of settings that worked:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<android.support.v7.widget.AppCompatTextView
android:text="7"
app:autoSizeTextType="uniform"/>
+13
source

I solved it programmatically

private TextView = findViewById(R.id.number_one);
TextViewCompat.setAutoSizeTextTypeWithDefaults(number1, TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM);

and XML:

  <TextView
        android:id="@+id/
        android:autoSizeTextType="uniform"
        android:gravity="center"
        android:text="1"  />
+1
source

Source: https://habr.com/ru/post/1681279/


All Articles