首页 > 解决方案 > 如何忽略“文本大小太小”

问题描述

如何忽略 Android Studio 中的“文本大小太小”警告?

例如,在我的一个 TextViews 中:

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:maxLines="3"
    android:singleLine="false"
    android:text="@string/navtask_btn_arrived"
    android:textAlignment="center"
    android:textSize="8sp"
    tools:ignore="textSize"/>

我试图添加:

tools:ignore="textSize"

tools:ignore="TextSize"

tools:ignore="SpUsage"

tools:ignore="spUsage"

tools:ignore="dimen"

它应该与“textSize”一起使用,因为文档中提到它可以与任何属性一起使用。

我知道其中一些没有任何意义,但是,嘿,为什么不在这里问之前尝试一下呢?

有任何想法吗?

标签: androidandroid-layout

解决方案


您需要添加属性tools:ignore="SmallSp"以删除警告使用SmallSp,其中SmallSp表示小的可缩放像素为

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:maxLines="3"
    android:singleLine="false"
    android:text="@string/navtask_btn_arrived"
    android:textAlignment="center"
    android:textSize="8sp"
    tools:ignore="SmallSp"/>

推荐阅读