Developer and Text Tools

Android dp, sp and px Explained: Densities, Icons and Layout Sizes

How Android turns dp and sp into pixels, which density bucket a phone uses, what size launcher and notification icons need, and how size classes work.

Saizul Amin
Saizul Amin3 Nov 2026 · 4 min read
Android dp, sp and px Explained: Densities, Icons and Layout Sizes

Every Android developer eventually ships a screen that looks perfect on their own phone and cramped or oversized on another. Almost always the cause is a size that was thought of in pixels instead of in density-independent units. This guide explains how Android measures things, how to move between dp, sp and px, and how to use the Android Screen Density Converter to get exact numbers for layouts and assets.

Why pixels do not work on Android

A pixel is a physical dot. A budget phone might have 270 dots per inch while a flagship has more than 500. A button 100 pixels wide is therefore almost twice as large on the cheaper screen. Android avoids this by asking you to design in density-independent pixels, or dp. One dp equals one pixel on a 160 dpi screen, which Android calls mdpi, the baseline density. On any other screen the system multiplies by the device density divided by 160.

The formula is simple: pixels equal dp times dpi divided by 160. A 48 dp button on a 420 dpi phone is 48 times 2.625, or 126 pixels. The point is that the button stays roughly the same physical size on every device, which is what users and their thumbs care about.

Text uses sp

Scalable pixels, or sp, follow the same density rule and are then multiplied by the font size the user chose in system settings. Someone who sets text to 130 percent sees 16 sp text rendered as if it were about 21 sp. Use sp for text and dp for everything else, including spacing and icons. Setting text in dp locks out people who need larger type, and accessibility scanners will flag it.

Recent Android versions scale very large text non-linearly so that headings do not explode in size, so treat the simple multiplication as an upper bound for big type.

Density buckets

Designers export bitmaps for named buckets: ldpi at 120 dpi, mdpi at 160, hdpi at 240, xhdpi at 320, xxhdpi at 480 and xxxhdpi at 640. Real phones rarely sit exactly on one of those values. A device that reports 420 dpi picks the nearest bucket, xxhdpi, and shrinks those images slightly. That is why it is worth exporting for the high buckets even if your test phone sits between them.

In the converter, choose a device preset or type the dpi, and it names the bucket and the scale factor. Then enter any value in dp, sp or px and the table shows the result in every bucket, plus the size of text at the font scale you pick.

Icon sizes that trip people up

Three icon types cause most of the questions:

  • Launcher icons are 48 dp. That is 48, 72, 96, 144 and 192 pixels from mdpi to xxxhdpi.
  • Adaptive icons use two 108 dp layers. Launchers cut them into circles, squircles or rounded squares that show the inner 72 dp, and only the central 66 dp is guaranteed to survive every mask, so keep the logo there.
  • Notification icons are 24 dp and must be white on a transparent background. Colour is ignored and a full-colour icon becomes a white square.

The icon tab lists these sizes for every bucket and exports them as CSV for a design hand-off. Play Store assets are separate: a 512 by 512 pixel icon and a 1024 by 500 feature graphic.

Screens, windows and size classes

Converting the screen itself is just as useful. A 1080 by 2400 phone at 420 dpi is about 411 by 914 dp. Modern Android layouts adapt using window size classes based on that width: compact below 600 dp, medium up to 839, expanded up to 1199, then large and extra-large. The same phone is compact in portrait and expanded in landscape, which is why a layout can switch from a bottom bar to a navigation rail when the user rotates.

The layout tab also gives the smallest-width qualifier, such as sw411dp, which older resource folders use, and a grid calculator. Enter columns, margins and gutters and it returns the exact column width in dp and pixels. On the phone above, four columns with 16 dp margins and 8 dp gutters are just under 89 dp each.

A quick workflow

  1. Pick your main test device from the presets or type its dpi.
  2. Enter the sizes from your design file and check them in every bucket.
  3. Export icon sizes for your designer.
  4. Convert the screen resolution to dp and confirm which size class your layouts must handle.
  5. Use the grid calculator to set column widths that add up.

Limits

Presets are typical configurations rather than a full device database, and system bars, cutouts and the display size setting reduce the usable window. To measure a real phone, run adb shell wm size and adb shell wm density. The converter does the maths; it does not resize images for you.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages