Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why android gives warning on using size smaller than 12sp?

Tags:

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

enter image description here

enter image description here

like image 301
Muhammad Irfan Avatar asked Mar 01 '13 12:03

Muhammad Irfan


People also ask

Should Use SP instead of dp for text size?

An sp is the same base unit (as dp), but is scaled by the user's preferred text size (it's a scale-independent pixel), so you should use this measurement unit when defining text size (but never for layout sizes).


2 Answers

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.

like image 115
CommonsWare Avatar answered Sep 27 '22 00:09

CommonsWare


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"/>
like image 44
AskNilesh Avatar answered Sep 25 '22 00:09

AskNilesh