Reputation: 1445
Hi Android developers,
I want to know how to choose the dimensions of drawables; for example, I have an image that I want to insert in my app, what size (pixel) the image should be to be inserted inside xxhdpi, xhdpi, hdpi, mdpi, and ldpi ?
I've analyzed many android apps on GitHub, they use random image sizes (pixel) for different densities.
Upvotes: 2
Views: 1277
Reputation: 83527
To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8:12:16 scaling ratio between the six generalized densities. For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screens, all the different sizes should be:
- 36x36 (0.75x) for low-density
- 48x48 (1.0x baseline) for medium-density
- 72x72 (1.5x) for high-density
- 96x96 (2.0x) for extra-high-density
- 144x144 (3.0x) for extra-extra-high-density
- 192x192 (4.0x) for extra-extra-extra-high-density
Source: https://developer.android.com/guide/practices/screens_support.html#DesigningResources
Upvotes: 2
Reputation: 463
Easiest way is to use Android Asset Studio. It will generate all the required resolution of images for respective screen densities
https://romannurik.github.io/AndroidAssetStudio/
Upvotes: 0
Reputation: 2063
I suggest you read this answer. It contains all information necessary to decide which units to use. TL;DR is: never use absolute values in pixels, instead, use dp units for views (including images), and sp for text.
Supporting multiple devices is covered here.
Also check the Material Design Guidelines to learn the commonly used dimensions for icons, margins, etc
Upvotes: 0