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

Possible Duplicate:
Difference of px, dp, dip and sp in android

I am new to Android and I was trying out this tutorial

In that tutorial, they used the unit "sp" for textSize attribute and "dp" for other attributes.

Please tell me how sp differs from 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.