【问题标题】:How to ingore "Text size is too small" [duplicate]如何忽略“文本大小太小” [重复]
【发布时间】:2018-10-08 06:51:20
【问题描述】:

如何忽略 Android Studio 中的“Text size is too small”警告?

例如,在我的一个 TextView 中:

<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”一起使用,因为文档中提到它可以与任何属性一起使用。

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

有什么想法吗?

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    您需要添加属性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"/>
    

    【讨论】:

      【解决方案2】:

      Android 中的最小文本大小为 12sp

      <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="12sp"
          tools:ignore="textSize"/>
      

      【讨论】:

      • 您可以根据需要使用较小的尺寸。 12sp 只是推荐的最小尺寸。
      【解决方案3】:

      Android Studio 报错:

      避免使用小于 12sp 的尺寸。所以尽量避免使用低于 12sp 的尺寸。 如果您仍想使用,请在该行下方声明。

      tools:ignore="SmallSp"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-12-23
        • 1970-01-01
        • 2018-05-31
        • 2020-07-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-10-17
        相关资源
        最近更新 更多