Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextView autoSizeTextType not working in Compat

I tried using autoSizeTextType. My minSdk is 24, all the tools are 26 and compat ist 26-beta2 as well.

Making them adjustable was tried through 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 it's currently bugged

like image 922
DeastinY Avatar asked Jul 12 '17 13:07

DeastinY


People also ask

How to make Text fit in TextView android?

To use preset sizes to set up the autosizing of TextView in XML, use the android namespace and set the following attributes: Set the autoSizeText attribute to either none or uniform. none is a default value and uniform lets TextView scale uniformly on horizontal and vertical axes.

How to change Text SIZE of TextView in android studio?

Go to File -> Settings, a new setting dialogue box will appear. Then go to Editor -> General. Now mark the checkbox Change font size with Ctrl + Mouse wheel and click on Apply button. Now to change your editor font size, you just have to press and hold Ctrl and rotate the Mouse wheel.

What is AppCompatTextView?

AppCompatTextView widget enhanced with emoji capability by using EmojiTextViewHelper . A TextView which supports compatible features on older versions of the platform, including: Allows dynamic tint of its background via the background tint methods in androidx. core.


1 Answers

Okay, so the 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"/>

You also need the appcompat-v7 library as a dependency in your module build.gradle file.

dependencies {
    implementation 'com.android.support:appcompat-v7:27.1.1'
}
like image 175
DeastinY Avatar answered Sep 16 '22 14:09

DeastinY