English 中文(简体)
Android 2.1 bug: uses res/layout-v3 instead of res/layout
原标题:

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.

最佳回答

I ve tested several devices and emulators (although not very thoroughly), and it seems that the selected resource folder is the one with the higher version <= device version.

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签