When you develop or test Android apps, the visual layout can look dramatically different on phones with varied screen densities (dpi) and resolutions. Relying on a single device often hides layout bugs that only appear on low‑dpi tablets or high‑dpi flagship phones. This tutorial shows you how to simulate those environments on the same device without rooting, using ADB commands, the built‑in "Smallest width" setting, and manufacturer‑specific options.
Android classifies screens by density buckets (ldpi ≈ 120 dpi, mdpi ≈ 160 dpi, hdpi ≈ 240 dpi, xhdpi ≈ 320 dpi, xxhdpi ≈ 480 dpi, xxxhdpi ≈ 640 dpi). The system scales resources (drawables, layout dimensions) according to the current densityDpi value. If an app only uses dp units, it should scale automatically, but many developers still hard‑code pixel values or use images that only exist in certain buckets. Testing across densities helps you spot those issues early.
adb devices. You should see your device listed as device.
adb devices List of devices attached 1234567890abcdef device
unauthorized, confirm the USB debugging prompt on the phone.adb shell wm density. The output looks like Physical density: 420 (the value varies by device).VALUE with your chosen DPI:
adb shell wm density VALUE
adb shell wm density again. The output should now show Override density: VALUE.adb shell wm density reset
adb shell wm density – it should now display Physical density only.Resolution defines the absolute pixel dimensions (e.g., 1080×2400). Some apps behave differently when the physical size changes, even if the DPI stays the same. Android’s wm size command lets you simulate a different resolution.
adb shell wm size. Example output: Physical size: 1080x2400.720x1520.
adb shell wm size 720x1520
adb shell wm size again. The output should read Override size: 720x1520.adb shell wm size reset
adb shell wm size – it should now show only Physical size.Starting with Android 7.0 (Nougat), the system exposes a "Smallest width" setting that effectively changes the logical density without touching the hardware DPI. This method works on any device that shows the option, even if ADB is unavailable.
320) to simulate a smaller screen, or a higher number (e.g., 480) to simulate a larger tablet‑like screen.Note: Not every OEM exposes this field. Samsung, OnePlus, and Pixel devices typically do; some heavily skinned ROMs hide it.
Some OEM skins ship with a built‑in "Screen resolution" or "Display size" toggle that adjusts both DPI and logical size. These settings are useful when you cannot use ADB (e.g., on a locked‑down work phone).
HD (720×1480), FHD (1080×2220), or WQHD (1440×2960). The change takes effect after a short restart.These UI options are convenient but often limited to the resolutions the manufacturer programmed. For more granular control, fall back to the ADB methods above.
After you apply any of the methods, you’ll want to confirm that the device truly reports the new values. Two quick ways:
adb shell getprop ro.sf.lcd_density returns the current logical density. For resolution, adb shell wm size shows the overridden size.drawable‑hdpi). If the high‑resolution version appears on a low‑dpi setting, the override worked.Warning: Changing DPI or size can make the system UI (status bar, navigation buttons) partially invisible on some devices. If you cannot navigate back to Settings, use the following recovery steps.
android:forceDark or custom Resources overrides.80 or higher than 640. Extreme values can break the UI and may require a factory reset.wm density override, which persists until you run reset.Below is a typical sequence you might follow when testing a new layout:
adb shell wm density adb shell wm size
adb shell wm density 120 adb shell wm size 720x1520
adb shell wm density 480 adb shell wm size 1440x3040
adb shell wm density reset adb shell wm size reset
This loop can be scripted for automated testing, but the manual steps above give you full control and immediate visual feedback.
Simulating different screen densities and resolutions on a single Android device is a powerful, no‑root technique for developers, QA engineers, and power users who want to verify UI robustness. By leveraging ADB’s wm density and wm size commands, the built‑in "Smallest width" developer option, or OEM‑specific display settings, you can reproduce a wide range of device form factors without buying hardware. Remember to back up your original values, stay within safe DPI ranges, and use the troubleshooting steps if the UI becomes unresponsive. With these tools in your toolbox, you’ll catch layout bugs early and deliver a more polished experience to every Android user.









