Android TextView autoSizeTextType not working



我想使用autoSizeTextType在单行中呈现文本。但是当我执行以下代码时,它不能正常工作。例如,数字1012呈现为->第一行:101,第二行:2

<TextView
android:id="@+id/tv1"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginLeft="50dp"
android:layout_marginTop="4dp"
android:layout_marginRight="50dp"

android:autoSizeTextType="uniform"
android:background="@drawable/rounded_corner"
android:backgroundTint="@color/deepgreen"
android:gravity="center"
android:padding="65dp"
android:textAlignment="center"
android:textColor="@color/white"

app:circularflow_radiusInDP="20dp"
app:layout_constraintBottom_toTopOf="@id/guideline2"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/zeroo"
app:layout_constraintVertical_bias="0.0" />

如果你知道你的文本只有一行,android:lines="1"应该这么做。

这也将工作,如果你知道你的文本总是有一些固定的行数:只需设置android:lines为该数字。不幸的是,如果行数是可变的,它就不起作用了。

最新更新