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

3

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

Overstreet answered 1/3, 2013 at 12:9 Comment(4)
Hi i think it will not allow below 12sp for large-screens , so you are getting error message in XML please change the device in preview screen and check itFlowers
Software Developers bothers only for errors, not for warnings :PTricuspid
ironically, the text in your screenshots is too small to read...Daryn
@Tricuspid You should add Non-Professional in the start of your line.Grigson
S
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.

Scallop answered 1/3, 2013 at 13:38 Comment(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?Fled
@Gaurav: I wouldn't. Ask your boss, not me. :-)Scallop
@Scallop 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?Esperanto
@RohanBhatia: "So why would they do it?" -- you would have to ask Google, specifically whoever is in charge of the Gmail UI.Scallop
R
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"/>
Rockoon answered 19/5, 2018 at 7:16 Comment(0)
H
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" />

Henderson answered 3/5, 2023 at 9:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.