Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto-size TextView with API before 26

I am trying to auto-size my TextView to fit in a specific width on one line, it was quite easy for API 26 and above, however, I want to support my app for use with APIs back to Lolipop. I am having a hard time trying to do this with java code. Can anyone help me? Thank you.

like image 645
Aden Diamond Avatar asked Sep 11 '25 07:09

Aden Diamond


2 Answers

Yes you can !

replace

android:autoSizeTextTyp="uniform"

with :

app:autoSizeTextType="uniform"

(At least working on sdk 23, with a simple TextView)

like image 185
Arnaud Avatar answered Sep 12 '25 22:09

Arnaud


You can use the support library for older APIs https://developer.android.com/guide/topics/ui/look-and-feel/autosizing-textview.html

like image 36
Ivan Wooll Avatar answered Sep 12 '25 20:09

Ivan Wooll