With all those Android devices out there, as a developer you bound to encounter one that is really annoying.
The ZiiO 7" is such: It is an Android 2.1 tablet with a 'large', 'long', 'mdpi' resources qualifiers, which makes it an odd device. Most tablets are marked as 'large', 'hdpi', so they use the same resources (specifically, drawables) as other Android hdpi devices.
Naive solution
To make the UI look good, the ZiiO7 requires some of the hdpi drawables and some of the mdpi resources, so the only way to do it is by creating a new folder in the application resources folder named 'drawable-large-mdpi', and copy there the mdpi or hdpi images.
This is nice, but since we also want to support 'large-hdpi', and since Android has a very strict "How Android Finds the Best-matching Resource", it means that we also need to create 'drawable-large-hdpi' folder to handle hdpi tables (like the Samsung Tab) - which will result in a huge APK, due to resources duplication, and a maintenance nightmare when revisiting the icons. We don't want that nightmare, right?
The best solution I found
After looking around, I noticed the resource alias option in Android aapt mechanism. Basically, I can make a resource reference to another resource by providing an XML instead of PNG file. The XML will be of type 'bitmap' and will point to a real drawable:
or, if the image is a 9 patch, you should use:
How to
I wanted to have the images in 'drawable-large-hdpi' and 'drawable-large-mdpi' are the same as in 'drawable-hdpi':- In the 'drawable-hdpi' I'll rename all the files to [real_resource_name]_hdpi.png and move them to 'drawable-nodpi' folder. It is important to move them to the nodpi folder, since we do not want Android resize them.
- Create a new XML file named [real_resource_name].xml with the alias text mention above. Remember that it needs to point to the renamed file! In our example '[real_resource_name]_hdpi.png'
- Copy the newly created XML file to 'drawable-hdpi', 'drawable-large-hdpi' and 'drawable-large-mdpi' folders.
- Run you application to see that it all works. You might want to delete some of the resource, or point them to a different resource. I, for instance, wanted that some of the images ZiiO7 uses are mdpi.