I have a background that I need fit in all screen sizes. I have three folders, hdpi
, ldpi
and mdpi
for drawables, but in the emulator there isn't any referense to what resolution hdpi
is and what mdpi
and ldpi
are.
You should read Supporting multiple screens. You must define dpi on your emulator. 240 is hdpi, 160 is mdpi and below that are usually ldpi.
Extract from Android Developer Guide link above:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
UPDATE: 30.07.2014
If you use Android Studio, make sure you have at least 144x144 resource and than use "FILE-NEW-IMAGE ASSET". Android Studio will make proper image files to all folders for you : )
As documentation says, adjust bitmaps as follows:
Almost every application should have alternative drawable resources for different screen densities, because almost every application has a launcher icon and that icon should look good on all screen densities. Likewise, if you include other bitmap drawables in your application (such as for menu icons or other graphics in your application), you should provide alternative versions or each one, for different densities.
Note: You only need to provide density-specific drawables for bitmap files (.png, .jpg, or .gif) and Nine-Path files (.9.png). If you use XML files to define shapes, colors, or other drawable resources, you should put one copy in the default drawable directory (drawable/).
To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8 scaling ratio between the four generalized densities. For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screen (the size for a launcher icon), all the different sizes should be:
36x36 for low-density (LDPI)
48x48 for medium-density (MDPI)
72x72 for high-density (HDPI)
96x96 for extra high-density (XHDPI)
144x144 for extra extra high-density (XXHDPI)
192x192 for extra extra extra high-density (XXXHDPI)
The documentation is quite sketchy as far as definitive resolutions go. After some research, here's the solution I came to: Android splash screen image sizes to fit all devices
It's basically guided towards splash screens, but it's perfectly applicable to images that should occupy full screen.
Check out this awesome converter. http://labs.rampinteractive.co.uk/android_dp_px_calculator/
精彩评论