Why android gives warning on using size smaller th

2019-02-16 07:50发布

问题:

Well, I am developing app for 7 inch tablet, more specially for nexus 7, and in the XML layout file, i get warning

Avoid using sizes smaller than 12sp: 11sp

if i set the size of any textField to less than 12sp ?

I am adding screen shots for more clarity of the problem

回答1:

For the default font scaling, 1sp = 1dip = 1/160". A height of 11sp is about 1/15th of an inch, which is pretty tiny.

This is a Lint error. You can override it -- press <Ctrl>-<1>, and the quick-fix list menu should give you the ability to suppress the message.

But, if you try 12sp, you will probably see that it too is very tiny, and that you want a larger font anyway.



回答2:

You can use tools:ignore="SmallSp" to ignore that warning

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="false"
    android:text="NileshRathod"
    android:textSize="8sp"
    tools:ignore="SmallSp"/>