7

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?

dsolimano
  • 8,870
  • 3
  • 48
  • 63
user3811793
  • 71
  • 1
  • 1
  • 3
  • 2
    Provide the developer a **ttf** (vectorial) font, so the developer can use sp. sp is **not** a PhotoShop unit. And **NO**, `px != sp`. It's only the same at **mdpi** resolution (160 dpi). As an alternative, provide all the required glyphs in all the resolution-scaled variants. – Phantômaxx Nov 03 '14 at 08:42
  • 2
    Related: [What's the difference between sp, px, and the others?](http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-in-android) – Andrew T. Nov 03 '14 at 08:44

4 Answers4

5
  • 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

Himanshu Agarwal
  • 4,623
  • 5
  • 35
  • 49
3

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.

Anfuca
  • 1,329
  • 1
  • 14
  • 27
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/

Community
  • 1
  • 1
Jared Rummler
  • 37,824
  • 19
  • 133
  • 148
0

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/

YaswanthJg
  • 130
  • 11