Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scale-independent pixel

Tags:

android

I don't know how it convert to the unit of pixels. For example, if I assign 10sp to my font size on 160 dpi device, how much px of my font size is it ? Or, if I assign 10sp to my font on 240 dpi device, how much px of my font size is it ?

like image 756
AechoLiu Avatar asked Mar 13 '11 12:03

AechoLiu


1 Answers

They're just the same as dip, but they also take into account the font scaling factor that the user sets on his device. So if he/she left font size set to "normal", it's just like dip. If there is a font scaling factor, you can get the whole scaled density from DisplayMetrics.scaledDensity.

(I have to admit I just tried to look for some "font size" option in my Android phone global settings and I couldn't find it, so I wonder if it is of any use right now. Am I missing something?)

like image 136
bigstones Avatar answered Oct 21 '22 22:10

bigstones