I’ve put on Github a quick example of how Density Specific Resources are used on Android in Appcelerator Titanium. I did this because I wanted to understand how big my images needed to be for the ‘top’ Android devices on my current project. I did the Android version originally when my client didn’t have an Android phone to test on. I just used 1x images in the default Android/images folder. Now, he has a S3 and think the graphics are ‘blurry’. I use ‘dips’ for the layout and fonts, so that works really well between devices. It is just the images I need to improve.
Here is the summary:
res-xhdpi (Samsung Galaxy Nexus, Samsung Galaxy S3 – 720×1280) 2x the size of dps. Use the same @2x images for iPhone. i.e. 100dp = 200px.
res-hdpi (Samsung Galaxy S, Samsung Galaxy S2, HTC Desire HD, HTC Incredible S – 480×800) – 1.5x size of dps. i.e. 100dp = 150px.
res-mdpi (HTC Desire 2.5) – Same as iPhone images i.e. 100dp = 100px
res-ldpi (people who need a new phone) – .75x size of dps. i.e. 100dp = 75px
I’ve also thrown in some sample splash screen sizes for reference.
All the apps I have developed are Portrait only, so I dont worry about ‘land’ folders. The only other screen resolution that I saw in my stats was the HTC Sensation 4G at 540×930 (3.34% of users) It should use hdpi, the screen will just be 360dp wide instead of 320dp.
Other things I found out:
There is a sporadic bug in building for the Android device. Make sure you do a clean before you deploy to your device as sometimes deploying to the Emulator removes all drawables from the build directory. If you don’t see the images on your device, check your build/android/res/drawable-xxx directories and make sure the files are there.
In the future, I may create a script to generate the correct image files from a @2x image using ImageMagick, much like Bob Sims did with Splash Screens. I also want to get the icons figured out correctly. I’ll post my findings on that later.