In addition to the general res/layout
folder I have a res/layout-v3
folder for backward compatibility with Android 1.5, which has problems
with some RelativeLayout
layouts.
It works perfectly with all phones and emulator versions tested so
far. Except of 2.1 (emulator and Nexus One). They choose to display
the Android 1.5 layout (res/layout-v3
) instead of the default res/
layout
.
Can anyone else confirm that? Is this an Android OS bug? If so, where is the best place to submit the bug report?
UPDATE:
After reading up on https://developer.android.com/guide/practices/screens_support.html#qualifiers again (thanks Mark for the hint), especially this part
Resources that are for use only on a specific API Level or higher. For example, if your application is designed to run on both Android 1.5 (API Level 3) and Android 1.6 (API Level 4 and higher), you can use the -v4 qualifier to tag any resources that should be excluded when your application is running on Android 1.5 (API Level 3).
I changed my layout order from having
- res/layout-v3 (for Android 1.5 only -> this was a wrong assumption I made)
- res/layout (for anything else)
to my new configuration of having:
- res/layout-v4 (for Android 1.6 and higher)
- res/layout (for anything else -> in this case this would be Android 1.5 only)
If I understand the above documentation right and if my assumptions in the parentheses are correct this time it should work now. However, the result is the following:
- Android 1.5 is using res/layout -> OK
- Android 1.6 is using res/layout-v4 -> OK
- Android 2.0 is using res/layout -> NOT OK
- Android 2.1 is using res/layout-v4 -> OK
So why is Android 2.0 (on both Emulator and Motorola Milestone) not picking the right layout resource folder?
I tested it then again with 2.0.1 and it seems to work there. So that seems to be a bug in 2.0 which got fixed in 2.0.1
But now the weirdest thing: in order to make it somehow run on 2.0 I copied the res/layout-v4 folder to res/layout-v5 to force Android 2.0 using this layout resource. Didn t work. But then I tried copying it to res/layout-v6 (which is supposed to be Android 2.0.1) and voilà all the sudden it works with 2.0. Very strange! But I hope this workaround will help a few other people out there.