Android自动文字大小调整无法正常工作

时间:2018-06-04 07:41:16

标签: android textview android-appcompat autosize

我试图通过添加自动调整大小文本选项来使我的应用程序响应,但它似乎无法正常工作。我使用的是android auto size标签:

 <TextView
        android:id="@+id/textView11"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="60px"
        android:paddingTop="160px"
        android:text="@string/greetings1"
        android:textColor="@color/black"
        app:autoSizeTextType="uniform"
        app:autoSizeMinTextSize="5sp"
        app:autoSizeMaxTextSize="100sp"
        app:autoSizeStepGranularity="2sp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:ignore="MissingPrefix" />

当我在手机上运行时,它根本不会调整大小。 请帮忙

1 个答案:

答案 0 :(得分:1)

来自Autosizing TextViews

  

如果在XML文件中设置自动调整大小,则不建议使用   价值&#34; wrap_content&#34;对于layout_width或layout_height属性   一个TextView。它可能会产生意想不到的结果。

你应该绑定高度

android:layout_width="match_parent"
android:layout_height="50dp"
相关问题