Android units – pixels, density, dpi, dip, dp, dps, sp, sip

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 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’s UI is highly recommended, as a way of ensuring proper display of your UI on different screens.

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.

Lower resolution screen Higher resolution, same size
Physical Width 1.5 inches 1.5 inches
Dots Per Inch (“dpi”) 160 240
Pixels (=width*dpi) 240 360
Density (factor of baseline 160) 1.0 1.5
Density-independent Pixels (“dip” or “dp” or “dps”) 240 240
Scale-independent pixels (“sip” or “sp”) Depends on user font size settings same

Notes: Density does not exactly follow the real screen size, pixels are not necessarily squares, there is no strict definition for what a “pixel” means. This may be a little confusing but not as much as CSS Units (em, ex, pt, etcetera).

This entry was posted in Android, Mobile, Uncategorized. Bookmark the permalink.

24 Responses to Android units – pixels, density, dpi, dip, dp, dps, sp, sip

  1. Pingback: Widget Androïd : customisation des barres de progression horizontales | La java de Kaerith

  2. Coryn says:

    Great Article!

    I’ve just started developing android apps, And was finding it quite difficult understanding all the different types of measurements. This helped heaps!


  3. Edwin Evans says:

    Thanks for your comment! You’re very welcome.

  4. Clancy says:

    This still does not make sense, I am try to spec out my PSD for the dev team, doc is 480×800 @ 160 DPI which is baseline MDPI.

    The font in the header is: 11.25pt do i do 11.25 x 160 / 72 = 25SP but what is 25 SP in DP?

  5. Edwin Evans says:

    @Clancy Specify the font in DP if you don’t want it to depend on the font size setting. I guess what you want is 25 DP.

    • michelle says:

      I don’t understand it. SP=Dp?

      • Edwin Evans says:

        I think the deal is, sp=dp unless the user has changed font preference. I’m not sure if there are phones that support that now, but potentially somebody who was weaker vision could set font size larger to be able to read better, so using sp will accommodate better accessibility… but if you need it to fit within a specific space that can’t grow to support larger fonts, then you have to use dp — not as friendly but will fit into the less dynamic layout well.

  6. Mooonbuggy says:

    Thanks for the article. If 1 DP is equal to 1 physical pixel on a 160 DPI screen, then it is .75 of a pixel on a low density screen….but what I don’t understand is, how do you represent fractions in code (not in XML), I mean I’m casting the result to an int value and on a 160 dpi screen I want to move a small graphic at 1 pixel increments which is fine, but on a low/120 DPI screen, the result [ from, for example........Increment=(int) (1 * (dpi/160)) ] is ’0′ so the graphic never moves, I can’t work with floats as it messes up the physics routines…..any ideas? Sorry if it’s not clear……..

  7. Sethuraman says:

    Dear Edwin Evans,

    With reference to your question posted in Stack overflow dated Sep 14, 2011, ( “Our device relies on a built-in windows driver (usbser.sys). Do we still need to go through WHQL testing or can we install in such a way that the user won’t see a warning about not passing Logo testing? I found but it’s not clear to me if this will do what I want. Does it matter whether I use DPInst program or have my own program that calls DriverPackagePreinstall?”

    I have similar doubts and thought you might be the right person to help me on it. kindly please reply to .

    # I created a PnP driver installation package with DPInst, for USB device with native usbser.sys driver. I created my own .inf file. The inf is working fine in all versions of windows.

    1) do i need to sign the usbser.sys though its a windows default or native driver?? Is already signed?

    2) As per my understanding, can i sign my .inf by self-signing to avoid certification warnings??

    I followed the following process to sign my inf ( please correct me if am wrong!! )

    # creted .cat file using Inf2cat.exe
    Inf2Cat.exe /driver:”"

    # created certificate using makecert.exe
    MakeCert.Exe -r -pe -n CN= -sv -len 2048

    3) As per the MS DDK Documentation, the test signing or Self Signing is done without PVK… Am i wrong in the last step?
    Please refer the below link for the steps i followed:

    # Create Software Publisher’s Certificate (SPC) from our certificate

    # Create a .pfx file
    pvk2pfx.exe -pvk -pi -spc ”

    # Sign the catalog file
    signtool.exe sign /f “” /p /t /v “”

    # Installed the certificate in local machine
    certmgr.exe /add “” /s /r localMachine root
    certmgr.exe /add “” /s /r localMachine trustedPublishers

    using above steps i creted the certificate and now while installing the package there is no ” certificate warning “.

    4) my doubt at this point is, can i distribute or publish this signed certificate?? i.e Can i install my self signed certificate in my clients machine ( is it legal to distribute my signed certificate for commercial use). Please condsider that there won’t be any objection from clients side where i want to install the certificate.
    Please clarify me. ( ). As for as my concerned, i am self signing only the INF file and not sys file, so i am allowed to resdistribue? Kindly provide me the MS Links for reference.

    Thanks in advance.


  8. Alice says:

    Hi everybody,
    I am new to this. Can I specify a html element width in dp? For example:

    Cabin in the woods

    If not, how is dp used?
    Thanks a lot!

  9. Excellent article. There are just so many units in Android it can be confusing. That’s what you get when you aren’t Apple and don’t have two screensizes with predictable resolutions.

  10. Pingback: android Measurement Units «

  11. Pingback: Mengenal ukuran di android pixels, density, dpi, dip, dp, dps, sp, sip | " Knowledge for Humanity "________________Nikmat tuhan yang mana yang dapat kamu ingkari

  12. Pingback: Mengenal Android |

  13. gopal says:

    vey nice..

  14. Thank you for this article. Is there a book where you can read about the specification details for these font types / sizes?

  15. rajesh says:

    Nice Article, for clarity of screen resolution.

  16. JLA says:

    For the same of having clear information out there, I have a couple recommendations that could help clarify this article.


    “The conversion of dp units to screen pixels is simple: pixels = dps * (density / 160)”

    In the table, “Density” is listed as a factor (i.e. 1.0, 1.5). The formula above uses “density” as an actual number (i.e. 160). This has the potential to create some confusion and could use clarification.


    “The conversion of dp units to screen pixels is simple: pixels = dps * (density / 160)”

    The table says dp is the same as dps, assuming this is the case it would be better to use one term instead of being inconsistent throughout the explanation. For example, the quote above uses dp and dps.

    Cheers -

  17. Michael Pohoreski says:

    You have a broken link – looks like w3schools moved their CSS Units page to:

  18. Clean and neat article.

  19. sxsds says:

    How can i get Deference in between tablet and device screen ?

Leave a Reply

Your email address will not be published. Required fields are marked *


one × 8 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>