20

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

Muhammad Irfan
  • 1,447
  • 4
  • 26
  • 56

3 Answers3

21

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 4
    I explained same thing to my designer, but he wants text size as 7sp, in some cases. So we designed one screen with his specs and he says it looks cool. :P Should we use it? – Sachchidanand Feb 22 '17 at 13:20
  • 5
    @Gaurav: I wouldn't. Ask your boss, not me. :-) – CommonsWare Feb 22 '17 at 13:25
  • 2
    @CommonsWare I was making a CardView something similar to what show up when we attach files in Gmail. So, I used 12sp size for the TextView that displays the size info of the file. When I compared the result to that of Gmail app's I arrived to the conclusion that they were using a size smaller than 12sp. So why would they do it? – Rohan Bhatia Jun 20 '17 at 15:09
  • 4
    @RohanBhatia: "So why would they do it?" -- you would have to ask Google, specifically whoever is in charge of the Gmail UI. – CommonsWare Jun 20 '17 at 15:10
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"/>
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
0

I'm using Android Studio Flamingo | 2022.2.1 Patch 1.

Avoid using sizes smaller than 11sp.

You should add to tools:ignore="SmallSp"

<TextView
        android:textSize="10sp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:ignore="SmallSp" />

Halil Ozel
  • 2,482
  • 3
  • 17
  • 32