Scaled Pixels in Android

On a TextView component, you can specify an integer for the size of the font and string suffix to indicate what type of units

  • px – pixels relative to the device that is rendering it
  • dp – density-independent pixels where 1dp is one physical pixel on a 160dpi screen
  • sp – scaled pixels are like dp pixels except they are scaled up or down relative to the user’s font size preference. For example, if you have an older user who may have their OS font preferences set to large text. 12sp will appear consistent with the rest of the displayed text whereas 12dp will show the absolute 12dp text which will appear small relative to everything else
  • in – inches (imperial)
  • mm – millimeters (metric)

TextView Documentation
StackOverflow – What’s the relationship between pixels and scaled pixels


Google+ Comments

About the author

Mark Lapasa

Mark Lapasa is a mobile developer who has released Native Android apps for both phones and tablets. He collaborates with business analysts, development and design teams to deliver engaging user experiences at the client-tier. He has many years of experience developing user interfaces for Enterprise Mobile, Healthcare, Financial, Social Gaming, and Online Gambling sectors. He blogs at http://knowledge.lapasa.net