Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Photoshop file font size is 20px what sp will be for this in android? Is its same? means 20px= 20sp or something else?

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?

like image 717
user3811793 Avatar asked Nov 03 '14 08:11

user3811793


2 Answers

  • 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

like image 98
Himanshu Agarwal Avatar answered Sep 23 '22 00:09

Himanshu Agarwal


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.

like image 37
Anfuca Avatar answered Sep 21 '22 00:09

Anfuca