Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should we use sp for font sizes in Android? [duplicate]

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).

What is SP in font size?

SP: is an abbreviation for Scale independent pixels. It is the same as the dp unit, but it is additionally scaled according to the user's font size selection.

What is the importance of changing the font size?

Font size can direct the attention of the user Using larger fonts as headings and titles can really grab the attention of the user, and help them to slow down while scrolling through your website. The best practice is to use this above the fold, to really draw users into your website.

Which unit is best for text size on android?

Best unit for text is sp and for dimensions best unit is dp.


The dp has constant ratio transition to px: dp = px * ratio. Where ratio will never change on any particular device.

While sp (s for scaled) has scalable ratio: sp = px * ratio * scale. Where ratio never changes, but scale is user configurable. This scale can be used by people who need larger font sizes, for example, to use device more comfortably.


Sp is scaled independently with respect to the normal font size of the device. http://developer.android.com/guide/practices/screens_support.html

Similarly, you should prefer the sp (scale-independent pixel) to define text sizes. The sp scale factor depends on a user setting and the system scales the size the same as it does for dp.