skip to Main Content

In Photoshop file font size is 20px. What sp will be for this in Android? Is it the same, that is, 20px = 20sp or something else?

Developer is asking for sp not px. How can I know or define sp in Photoshop?

4

Answers


  1. They are different and you should be using sp and not px. Please see this stackoverflow post

    sp

    Scale-independent Pixels – this is like the dp unit, but it is also
    scaled by the user’s font size preference. It is recommend you use
    this unit when specifying font sizes, so they will be adjusted for
    both the screen density and user’s preference.

    This tool is handy for converting px to sp or dp: http://pixplicity.com/dp-px-converter/

    Login or Signup to reply.
    • px is one pixel.
    • sp is scale-independent pixels.
    • dip is Density-independent pixels.

    You would use

    • sp for font sizes
    • dip for everything else.

      dip==dp

    From Android Developers center:

    px
    Pixels – corresponds to actual pixels on the screen.

    in
    Inches – based on the physical size of the screen.
    1 Inch = 2.54 centimeters

    mm
    Millimeters – based on the physical size of the screen.

    pt
    Points – 1/72 of an inch based on the physical size of the screen.

    dp
    Density-independent Pixels – an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both “dip” and “dp”, though “dp” is more consistent with “sp”.

    sp
    Scale-independent Pixels – this is like the dp unit, but it is also scaled by the user’s font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user’s preference.

    You can use this to convert various options to convert between pixels sizes

    Login or Signup to reply.
  2. At mdpi resolutions, 1dp = 1px.

    At hdpi resolutions, 1dp = 1,5px.

    At xhdpi resolutions, 1dp = 2px.

    At xxhdpi resolutions, 1dp = 3px.

    At xxxhdpi resolutions, 1dp = 4px.

    Login or Signup to reply.
  3. Just use the px in your photoshop.!
    Since, you cant compare px to sp as there are seven variants of DPI!

    • xxxhdpi
    • xxhdpi
    • xhdpi
    • hdpi
    • mdpi
    • Idpi
    • tvdpi

    PX will be equal to DP at mdpi(160 dpi), but the SP will not…

        Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference.
        It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.
    

    calculating various values
    http://angrytools.com/android/pixelcalc/

    comparing various DPIs
    http://coh.io/adpi/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search