1. Definitions
- resolution = number of pixels available in the display, scale-independent pixel = sp
- density = how many pixels appear within a constant area of the display, dots per inch = dpi
- size = amount of physical space available for displaying an interface, screen's diagonal, inch
- density-independent pixel = virtual pixel that is independent of the screen density, dp
2. Density Classes
Class | Name | Density | Factor | Drawable Folder | Comment |
---|---|---|---|---|---|
ldpi | low density | 120 dpi | sp = 3/4 * dp | drawable-ldpi | |
mdpi | medium density | 160 dpi | sp = dp | drawable-mdpi OR drawable | baseline size, example: 320x480 (sp or dp) |
hdpi | high density | 240 dpi | sp = 1.5 x dp | drawable-hdpi | example: 480x800 sp = 320x533 dp |
xhdpi | extra high density | 320 dpi | sp = 2 x dp | drawable-xhdpi | |
xxhdpi | extra extra high density | 480 dpi | sp = 3 x dp | drawable-xxhdpi | |
xxxhdpi | extra extra extra high density | 640 dpi | sp = 4 x dp | drawable-xxxhdpi |
3. Icon Sizes (full / content)
Density | Launcher | Menu | Action Bar | Status Bar and Notification | Tab | Pop-up Dialog and List View | Small and Contextual |
---|---|---|---|---|---|---|---|
ldpi | 36x36 px | 36x36 / 24x24 px | 24x24 / 18x18 px | 18x18 / 16x16 px | 24x24 / 22x22 px | 24x24 px | 12x12 / 9x9 px |
mdpi | 48x48 px | 48x48 / 32x32 px | 32x32 / 24x24 px | 24x24 / 22x22 px | 32x32 / 28x28 px | 32x32 px | 16x16 / 12x12 px |
hdpi | 72x72 px | 72x72 / 48x48 px | 48x48 / 36x36 px | 36x36 / 33x33 px | 48x48 / 42x42 px | 48x48 px | 24x24 / 18x18 px |
xhdpi | 96x96 px | 96x96 / 64x64 px | 64x64 / 48x48 px | 48x48 / 44x44 px | 64x64 / 56x56 px | 64x64 px | 32x32 / 24x24 px |
xxhdpi | 144x144 px | (1) | (1) | (1) | (1) | (1) | (1) |
xxxhdpi | 192x192 px | (1) | (1) | (1) | (1) | (1) | (1) |
- (1) Google documentation says: "Applications should not generally worry about this density; relying on XHIGH graphics being scaled up to it should be sufficient for almost all cases."
- Launcher icons for Android Market: 512x512 px.
4. Screen Size Classes
Class | Size in dp | Layout Folder | Examples | Comment |
---|---|---|---|---|
small | 426x320 dp | layout-small | typical phone screen (240x320 ldpi, 320x480 mdpi, etc.) | |
normal | 470x320 dp | layout-normal OR layout | typical phone screen (480x800 hdpi) | baseline size |
large | 640x480 dp | layout-large | tweener tablet like the Streak (480x800 mdpi), 7" tablet (600x1024 mdpi) | |
xlarge | 960x720 dp | layout-xlarge | 10" tablet (720x1280 mdpi, 800x1280 mdpi, etc.) |
- valid for Android 3.1 and older
- for Android 3.2 and newer see: Declaring Tablet Layouts for Android 3.2
5. Example Screen Configurations
Screen Size | Low density (120), ldpi | Medium density (160), mdpi | High density (240), hdpi | Extra high density (320), xhdpi |
---|---|---|---|---|
small | QVGA (240x320) | 480x640 | ||
normal | WQVGA400 (240x400) WQVGA432 (240x432) | HVGA (320x480) | WVGA800 (480x800) WVGA854 (480x854) 600x1024 | 640x960 |
large | WVGA800 (480x800)(2) WVGA854 (480x854)(2) | WVGA800 (480x800)(1) WVGA854 (480x854)(1) 600x1024 | ||
xlarge | 1024x600 | WXGA (1280x800)(3) 1024x768 1280x768 | 1536x1152 1920x1152 1920x1200 | 2048x1536 2560x1536 2560x1600 |
- (1) To emulate this configuration, specify a custom density of 160 when creating an Android Virtual Device that uses a WVGA800 or WVGA854 skin.
- (2) To emulate this configuration, specify a custom density of 120 when creating an Android Virtual Device that uses a WVGA800 or WVGA854 skin.
- (3) This skin is available with the Android 3.0 platform.
6. Screen Orientation
Orientation | Name | Layout Folder, Example |
---|---|---|
port | portrait | layout-port-large |
land | landscape | layout-land-normal OR layout-land |
7. Best Practices
- Use wrap_content, match_parent, or dp units when specifying dimensions in an XML layout file.
- except for defining text sizes: sp (scaling depends on user setting)
- Note: fill_parent is deprecated since API level 8.
- Do not use hard coded pixel values in your application code.
- Do not use AbsoluteLayout.
- deprecated since Android 1.5
- alternative: RelativeLayout
- Supply alternative bitmap drawables for different screen densities.
- Provide a launcher icon for xxhdpi, but no other icons.
8. References
- New Tools For Managing Screen Sizes, Android Developers Blog
- Supporting Multiple Screens, Android Developers Guide
- Declaring Tablet Layouts for Android 3.2, Android Developers Guide
- Providing Alternative Resources, Android Developers Guide
- How Android Finds the Best-matching Resource, Android Developers Guide
- Android Design
- Iconography, Android Design
- Designing for Multiple Screens, Android Developers Training
- Platform Versions, Android Developers Device Dashboard
- Nick Butcher: Nexus 10 launcher icons
- List of Android Devices with pixel density buckets
3 comments:
Added xxhdpi to the the blog post.
Do you know the exact definition of 160 dpi being mdpi? Around 160dpi or at least 160 dpi? Is 159 mdpi?
My Galaxy Nexus has a dpi of 316. Is it hdpi or xhdpi?
/Lars
Lars,
the dpi values of the devices are rounded. For the Galaxy Nexus the official dpi value is 320, so it falls into the xhdpi bucket. Same for other devices, so you can assume a pragmatic rounding.
Best regards,
Stefan
Post a Comment