I have created my first project (after several tutorials and reading the Android Developers Dev Guide) and have a simple tiled background. Just to put my reading about supporting multiple screens to the test (http://developer.android.com/guide/practices/screens_support.html) I created a background tile for every dpi so I have one tile at 120 dpi, one at 160, one at 240, and one at 320. I put a letter in each tile respectively so the 240 has an H, 320 X etc. When I run the app in an AVD that supports the different densities the proper image is used. This is in perfect alignment with my reading.
What I am confused on is that I only have to have one drawable xml file and it can be about anywhere to work. Now the xml is all the same since I used the same image name just changed the dpi. So how does the system find my drawable file that is referenced from my layout xml? Does it search every drawable folder till it finds a match? If there are “common” purpose files such as this shouldn’t I maybe have a “common” drawable folder?
background.xml (aka my drawable)
<?xml version="1.0" encoding="utf-8"?><bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/ironmikebackgrnd" android:tileMode="repeat" android:dither="true" />
main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@drawable/background">
and my project folder structure (feel free to critique)….aaarrrgggg Guess I’m not allowed to post images yet. Go here to see the folder structure.
Eclipse Folder Structure
On further exploration I see that it get’s auto generated into the gen > R.Java directory. So that is how it is found but as for the project structure what would you reccomend for storing “global” / “common” type files.
You can put your background.xml in “drawable” folder. (With no qualifiers)
So it shall match and can be used regardless of the current screen resolution.