Android Jetpack: Autosizing TextView
Why Stack Overflow recommends it
Stack Overflow users link it as a quick, clear explanation of TextView autosizing when answering or asking questions about text that does not fit its view.
Recommended by 1 people across 1 different months, 2019 to 2020.
What it is
A short official Android Developers video introducing the autoSizeTextType property on TextView, added in Android O and available through Jetpack. It shows how text scales uniformly for dynamic content, and how to set minimum and maximum sizes, step granularity, or preset sizes.
What people said
Recommends iknow · 2020-10 · Stack Overflow · on “Text does not adapt to TextView”
To set optimal size of the text in TextView You can use autoSizeTextType property. To do it Your TextView must have fixed sizes or match_parent . Then You can use autoSizeTextType It looks something like this: <TextView android:layout_width="match_parent" android:layout_height="150dp" android:text="@string/lorem_ipsum" app:autoSizeTextType="uniform" app:autoSizeMinTextSize="12sp" app:autoSizeMaxTextSize="100sp" /> Results: TextView height : 150dp [LINK] TextView height : 300dp [LINK] Here is a short video on YouTube with great explanation [this video]
Cites amp · 2019-01 · Stack Overflow · on “Error inflating class TextView with AutoSizing”
I started using the Autosizing TextView [this video] and it works pretty well in most cases, exception in the following. I have a recyclerview and in the item layout I have the following TextView: <TextView android:id="@+id/title_tv" android:layout_width="0dp" android:layout_height="0dp" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:ellipsize="end" android:gravity="top|center_horizontal" android:maxLines="2" android:textColor="@color/e_white" app:autoSizeMaxTextSize="14sp" app:autoSizeTextType="uniform" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHeight_min="25dp" app:layout_constraintStart_toStartOf="par
Cites Muahmmad Tayyib · 2019-12 · Stack Overflow · on “Auto adjust text size to fit the layout Android”
as mentioned [this video] avoid using layout height to wrap content, instead use match_parent or specified height... otherwise this could cause unexpected results..