Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement autoSizeTextType in android Edittext

Android Oreo buildToolsVersion provides a simplified way to autoresize textsize in AppCompatTextView as follows

<android.support.v7.widget.AppCompatTextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    android:maxWidth="300dp"
    android:background="@android:color/holo_green_light"
    app:autoSizeTextType="uniform"
    app:autoSizeMinTextSize="5sp"
    app:autoSizeMaxTextSize="50sp"
    app:autoSizeStepGranularity="4sp"
    />

Can a similar implementation be applied to AppCompatEditText since it is basically an extension of TextView? Simply applying autoSizeTextType to AppCompatEditText doesn't seem to work. Is there a way to make this work out?

like image 857
SagePawan Avatar asked Sep 25 '17 13:09

SagePawan


People also ask

How to make Text size responsive in Android?

With Android 8.0 (API level 26) and higher, you can instruct a TextView to let the text size 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.

What is EMS in Edittext?

The em is simply the font size. In an element with a 2in font, 1em thus means 2in. Expressing sizes, such as margins and paddings, in em means they are related to the font size, and if the user has a big font (e.g., on a big screen) or a small font (e.g., on a handheld device), the sizes will be in proportion.

How to change font 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 autoSizeStepGranularity?

autoSizeMaxTextSize is the maximum size of textview it will take autoSizeMinTextSize is the minimum size of textview it will take and autoSizeStepGranularity is the size of each step.


1 Answers

No you cannot. Please see here; it is disabled for all AppCompatEditText since it is not supported.

like image 149
Siyamed Avatar answered Sep 17 '22 20:09

Siyamed