{"id":131,"date":"2011-02-03T17:12:06","date_gmt":"2011-02-04T01:12:06","guid":{"rendered":"http:\/\/blog.edwinevans.me\/?p=131"},"modified":"2016-09-07T11:40:35","modified_gmt":"2016-09-07T18:40:35","slug":"android-units-pixels-density-dpi-dip-dp-dps-sp-sip-oh-my","status":"publish","type":"post","link":"http:\/\/blog.edwinevans.me\/?p=131","title":{"rendered":"Android units &#8211; pixels, density, dpi, dip, dp, dps, sp, sip"},"content":{"rendered":"<p>The Android documentation for <a href=\"http:\/\/developer.android.com\/guide\/practices\/screens_support.html\">supporting multiple screen sizes<\/a> says:<\/p>\n<blockquote><p>The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, the baseline density assumed by the platform (as described later in this document). At run time, the platform transparently handles any scaling of the dp units needed, based on the actual density of the screen in use. The conversion of dp units to screen pixels is simple: pixels = dps * (density \/ 160). For example, on 240 dpi screen, 1 dp would equal 1.5 physical pixels. Using dp units to define your application&#8217;s UI is highly recommended, as a way of ensuring proper display of your UI on different screens.<\/p><\/blockquote>\n<p>Confused? Try this. Take the example of two screens that are the same size but one has a resolution of 160 dpi (dots per inch, i.e. pixels per inch) and the other is 240 dpi.<\/p>\n<table>\n<tbody>\n<tr>\n<td><\/td>\n<td>Lower resolution screen<\/td>\n<td>Higher resolution, same size<\/td>\n<\/tr>\n<tr>\n<td>Physical Width<\/td>\n<td>1.5 inches<\/td>\n<td>1.5 inches<\/td>\n<\/tr>\n<tr>\n<td>Dots Per Inch (&#8220;dpi&#8221;)<\/td>\n<td>160<\/td>\n<td>240<\/td>\n<\/tr>\n<tr>\n<td>Pixels (=width*dpi)<\/td>\n<td>240<\/td>\n<td>360<\/td>\n<\/tr>\n<tr>\n<td>Density (factor of baseline 160)<\/td>\n<td>1.0<\/td>\n<td>1.5<\/td>\n<\/tr>\n<tr>\n<td>Density-independent Pixels (&#8220;dip&#8221; or &#8220;dp&#8221; or &#8220;dps&#8221;)<\/td>\n<td>240<\/td>\n<td>240<\/td>\n<\/tr>\n<tr>\n<td>Scale-independent pixels (&#8220;sip&#8221; or &#8220;sp&#8221;)<\/td>\n<td>Depends on user font size settings<\/td>\n<td>same<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Notes: <a href=\"http:\/\/developer.android.com\/reference\/android\/util\/DisplayMetrics.html#density\">Density does not exactly follow the real screen size<\/a>, pixels are not necessarily squares, <a href=\"http:\/\/en.wikipedia.org\/wiki\/Pixel\">there is no strict definition for what a &#8220;pixel&#8221; means<\/a>. This may be a little confusing but not as much as <a href=\"http:\/\/www.w3schools.com\/cssref\/css_units.asp\">CSS Units<\/a> (em, ex, pt, etcetera).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Android documentation for supporting multiple screen sizes says: The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, the baseline density assumed by the platform (as described later in this document). At run time, the &hellip; <a href=\"http:\/\/blog.edwinevans.me\/?p=131\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,4,1],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.edwinevans.me\/index.php?rest_route=\/wp\/v2\/posts\/131"}],"collection":[{"href":"http:\/\/blog.edwinevans.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.edwinevans.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.edwinevans.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.edwinevans.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=131"}],"version-history":[{"count":21,"href":"http:\/\/blog.edwinevans.me\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":144,"href":"http:\/\/blog.edwinevans.me\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions\/144"}],"wp:attachment":[{"href":"http:\/\/blog.edwinevans.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.edwinevans.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.edwinevans.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}