I am new to Android and I just started creating an application. I want to place a back ground image for my app. What is the width and height of the image that I've to use so that it works on all the devices.
2 Answers
This touches a couple of different concepts. While both are covered in the rather long and cryptic Supporting Multiple Screens document, let me give a few heads up.
- You might need to read the document a few times. 
- Devices are grouped by pixel density and screen size. Pixel density is one of low (ldpi), medium (mdpi), high (hdpi), and the new extra-high (xhdpi). Screen sizes or small, normal, large, and the new extra-large. Also, there are two orientations: portrait and landscape. If you look at what actually contacts the Android Market, you can ignore everything except mdpi and hdpi for normal screens. 
- These groupings correspond to separate directories under the res/ directory tree of your project. In res/drawable go all your generic images. In res/drawable-mdpi and res/drawable-hdpi go your images when you have overridden them for the basic types. 
- Also, these groupings have overlap between "medium density" (about 140 to 180 dpi) and "high density" (about 170 to 250 dpi). For reference, the Motorola Droid X has a 854 pixel by 480 pixel phone in a 4.7" (diagonal) display for a density of 217 dpi. 
- You generally specify your layout resources in prescaled units (dp for graphics, at 1/160 per inch intervals or sp equivalent in text). See this question for more information. 
- The different measurements are needlessly confusing. Make a mdpi image at about 640 x 480 and a hdpi image at about 800 x 600 and you should be about right. Also, the aspect ratio is not guaranteed, you may need to use the 9-patch tool to make sure it stretches correctly. 
- If you really want to see the device resolution, you can ask for the getWindowManager().getDefaultDisplay().getWidth()/.getHeight() number of pixels. 
Happy Coding!
 
    
    - 1
- 1
 
    
    - 19,908
- 6
- 73
- 83
Since android doesn't have any specific resolution. We need this by different drawable folders. Better to refer this link
 
    
    - 34,521
- 28
- 94
- 112
