Mobile, Cloud & DevOps Tools

Android Screen Density Calculator

Convert between dp, sp and px for every Android density bucket, calculate a device's dpi from resolution and screen size, and list the icon and image sizes to export for mdpi through xxxhdpi.

  • Values in every bucket
  • Device dpi and bucket
  • Asset size table
Runs in your browser

Everything you paste, type or drop is processed in this browser tab. It is not uploaded, logged, stored or sent to analytics.

dp / px / dpi workspace

1 Convert a value

Examples:
Unit

Only used when the unit is px.

1.0 is the default system font size; Android offers roughly 0.85 to 2.0.

2 Your device (optional)

Custom asset size

Adds a row to the asset table with the pixel size for each bucket.

3 Pixels in every bucket

Your device

Asset sizes to export

What the Android Screen Density Calculator does

This calculator converts a size between dp, sp and px for every Android density bucket, estimates a device's physical density from its resolution and screen size, and lists the pixel sizes to export for icons and images from mdpi to xxxhdpi. A 48 dp launcher icon, for example, is 48 px at mdpi, 96 px at xhdpi and 144 px at xxhdpi.

Android measures layouts in density-independent pixels so that a button is roughly the same physical size on a cheap phone and a flagship. The conversion is one line - px = dp x dpi / 160 - but doing it for seven buckets, with the framework's rounding, is where mistakes creep in.

How to use it

  1. Enter a value and pick its unit. dp is for layout sizes, sp for text, px for a pixel measurement taken from a design file or a screenshot.
  2. If the value is in px, choose the density it was measured at - a mock-up drawn at 3x is xxhdpi (480 dpi).
  3. For sp, set the font scale you want to test. At the default scale of 1.0, sp and dp are the same.
  4. Optionally enter a device's resolution and diagonal to see its physical density, the nearest bucket, its screen size in dp and its smallest-width qualifier.
  5. Use the asset table to export icons at the right pixel size for each drawable folder, and add your own size under Custom asset size.

Reading the results

Exact px is the unrounded result of the formula. Rounded px is what the framework would use for a dimension resource: it rounds half up, and a non-zero size never rounds down to 0 px.

The nearest bucket for a device is an estimate. Each manufacturer chooses the density a device reports, and it is often not the one closest to the physical dpi - many 400-420 dpi phones report xxhdpi, some report 420 dpi exactly. Use the device's reported value, from adb shell wm density, when you have it.

Smallest width in dp is the figure the sw600dp and similar resource qualifiers compare against. Below 600 dp is a phone-sized compact width; 600 dp and above is where tablet layouts usually begin.

Worked example: a 6.4-inch 1080 x 2400 phone

The diagonal in pixels is the square root of 1,080 squared plus 2,400 squared, which is 2,631.8 px. Divided by 6.4 inches that gives 411.2 dpi.

That is closer to xxhdpi (480 dpi) than to xhdpi (320 dpi) on a ratio scale, so the calculator suggests xxhdpi. At 480 dpi the screen is 1,080 x 160 / 480 = 360 dp wide and 800 dp tall, a compact-width phone.

A 48 dp launcher icon at xxhdpi needs 48 x 3 = 144 px. Body text of 16 sp at a user font scale of 1.3 becomes 20.8 dp, which is 62.4 px at xxhdpi and is drawn at 62 px.

Formulas and scoring rules

dp to px
px = dp x dpi / 160160 dpi (mdpi) is the baseline where 1 dp is 1 px.
px to dp
dp = px x 160 / dpi
sp to dp
dp = sp x font scaleAndroid 14 and later scale large text non-linearly; the linear rule is exact for the default scale and a close guide otherwise.
Physical density
dpi = sqrt(width_px^2 + height_px^2) / diagonal_in
Rounding
rounded = floor(exact + 0.5); if exact > 0 and rounded = 0 then 1The rule TypedValue.complexToDimensionPixelSize applies to dimension resources.
Bucket scales
ldpi 0.75, mdpi 1, tvdpi 1.33, hdpi 1.5, xhdpi 2, xxhdpi 3, xxxhdpi 4

Which folders you actually need

For vector drawables you need only one file; the system rasterises it at the device's density. Bitmap assets such as photos or complex illustrations are what need a copy per bucket, and in practice hdpi, xhdpi, xxhdpi and xxxhdpi cover almost every device in use. Android's guidance is to supply xxxhdpi only for launcher icons, because some launchers show icons larger than their nominal size.

Launcher icons are best shipped as adaptive icons: two 108 dp layers, of which the middle 66 dp circle is guaranteed to be visible after the launcher applies its mask. Keep logos inside that safe zone.

Limitations: what the result does not prove

  • It does not know what density a particular device reports - only what its physical size implies. Check the device's own setting before designing to a single model.
  • Screen size in dp ignores system bars, display cutouts and the user's display-size setting, all of which change the space your layout really gets.
  • Non-linear font scaling on Android 14 and later makes very large sp values grow less than the linear formula shows.

Privacy: where your data goes

Everything you paste, type or drop is processed in this browser tab. It is not uploaded, logged, stored or sent to analytics. Session recording and tag-manager scripts are switched off on this page.

Standards and sources

Frequently asked questions

How many pixels is 1 dp on an xxhdpi screen?

Three. xxhdpi is 480 dpi, and 480 / 160 = 3, so every dp is 3 physical pixels. At xhdpi it is 2 pixels, at hdpi 1.5 and at xxxhdpi 4.

What is the difference between dp and sp?

Both start from the same density-independent unit, but sp is also multiplied by the user's font size preference. Use sp for text so it respects accessibility settings, and dp for everything else, including icon sizes and spacing.

Why does my phone report a different density from the one calculated here?

Manufacturers choose the reported density to get a layout size they like, and users can change it with the display size setting. The physical figure here is geometry; the reported figure is a design choice. Run adb shell wm density to see the value the system uses.

What size should an Android launcher icon be in pixels?

48 dp, which is 48 px at mdpi, 72 at hdpi, 96 at xhdpi, 144 at xxhdpi and 192 at xxxhdpi. For an adaptive icon, each layer is 108 dp, so 432 px at xxxhdpi, with the important content inside the central 66 dp.

Do I still need drawable folders for every density?

Not for vector drawables, which scale at run time. Raster images do need density variants, or the system scales one version up or down and it looks soft or wastes memory. Android App Bundles then deliver only the density a device needs.

How is a pixel size rounded when the result is fractional?

For dimension resources the framework rounds half up and never lets a non-zero size become 0 px. A 1 dp line at ldpi is 0.75 px and is drawn as 1 px; 20.8 dp at xxhdpi is 62.4 px and is drawn as 62 px.

Last reviewed by the A2Z.Tools team against the sources listed above.

Rate this tool

Was this tool useful? Your feedback helps us improve it.

No ratings yet — be the first to rate this tool.
Your rating (required)
0 / 2000

Please do not include passwords, payment details or other sensitive information.

Your feedback is sent privately to the A2Z.Tools team and will not be posted publicly.