tags:

views:

23

answers:

1

I feel as if I'm missing something.

In my application, I decided to provide alternative drawable resources and alternative layout files. My structure is as follows:

res/drawable-hdpi/filename.png
res/drawable-mdpi/filename.png
res/drawable-ldpi/filename.png

res/layout-small/layout.xml
res/layout-large/layout.xml
res/layout/layout.xml

I created three different emulators: one with the default HVGA, one with QVGA, and one with WVGA800

It doesn't seem to pick up those alternative resources/layouts based on screen size/density, or maybe i just can't tell?

Is there some way, other than using a device for each specific size, to test this? Or am I just missing something important?

Another question, how well does Android scale drawables if no alternative resource exist?

+1  A: 

A few points, in no particular order:

  • Layouts are related to screen size and thus to large, medium, small and drawables are related to density and thus to hdpi,mdpi,ldpi. It is obvious to some and not so easy to understand to others.
  • Read through this and create your emulator devices as specified in this page, double check to ensure you got them right.
  • Now start with just a simple layout and test it on the default device skin, then add layout-320x480, test, repeat for other sizes. If you are using layout-large/small etc, remember to add the correct lines to AndroidManifest.xml <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:resizable="true" android:anyDensity="true" />
  • One simple way to do this is to have a default layout.xml and drawables folder, and for different sizes have layout-320x480.xml etc folders and different densities we have drawables-hdpi etc folders. If you make sure to set android:anyDensity="false" /> in manifest file then the handset will get correct layouts and assets depending on its attributes.

If you set android:anyDensity="false" /> in manifest file the handset handles the sizing of drawables, typically taking assets from drawables folder and resizing it.

omermuhammed