What is the proper way to set my drawable directories to support the new Dell Streak without losing support for older devices?
This seems to be a widespread problem.
I have the following drawable directories:
drwxr-xr-x 18 mike staff 612 Feb 4 17:28 drawable/
drwxr-xr-x 51 mike staff 1734 Feb 4 17:32 drawable-nodpi/
drwxr-xr-x 44 mike staff 1496 Feb 4 17:30 drawable-normal-mdpi/
My xml drawable resources are in drawable. My resources intended for the large-mdpi (Dell Streak) and normal-hdpi (Droid, Nexus, Incredible, etc.) are all in drawable-nodpi. My resources for normal-mdpi (older phones like the G1) are in drawable-normal-mdpi.
Unfortunately, the normal-hdpi phones like the Droid are pulling their resources from drawable-normal-mdpi instead of from drawable-nodpi. This is likely because of the rules in How Android Finds the Best-matching Resource.
So the question is, how do I provide support for large-mdpi devices like the Streak along with normal-hdpi devices like the Droid, as well as normal-mdpi devices like the G1?
The simplest solution would probably be to make two copies of my large resources, one in normal-hdpi for the droid and one in large-mdpi for the streak, but i'd like to avoid duplicating all of these resources.
Update
Per Mayra's suggestion, I could make an alias for every resource. However, there are a lot of resources I'd have to make aliases for, which would make maintenance a nightmare going forwa开发者_开发问答rd, so I'm hoping for another solution.
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Rename your "drawable-nodpi" to "drawable-nodpi-800x480" (the nodpi needs to be in there, or it wont work!) and rename "drawable-normal-mdpi" to "drawable-480x320".
You can use an alias resource to provide a pointer to the resource without copying it. See Alias Resources
Have you tried putting the HDPI resources in just the drawable
folder and not drawable-nodpi
?
I asked the same question 2 days before you and the closest thing to a solution was using the alias resource (via Mayra). I ended up writing a python script to handle this for me. Its a really bad work around and I wish I had enough determination to create a more fool proof solution.
Just for reference, the shared resources belong in a nodpi
folder so they aren't scaled by android.
Check this guide: http://developer.android.com/guide/practices/screens_support.html
Basically, you should put your drawables in drawable-mdpi, drawable-hdpi, etc. and your layout files in layout-small, layout-medium, etc. directories. So, layouts should be screen size dependent and drawables should be screen density dependent.
精彩评论