My app has layout-v21 folder for Android 5.0. Do API22 and API23 devices use layouts in this folder or the from the default layout folder?
How does Android choose API specific resources?
Do API22 and API23 devices use layouts in this folder
Yes, unless there is a layout-v22 or layout-v23 directory. layout-v21 says to use that directory for API Level 21 and higher.
Related
How do i name a layout folder which for only between android 4.0 to 4.3?
I know how to do it for one version but not sure in between
The API level supported by the device. For example, v1 for API level 1
(devices with Android 1.0 or higher) and v4 for API level 4 (devices
with Android 1.6 or higher). See the Android API levels document for
more information about these values.
So, you need just create directory for Android 4.0 (v14), and other for API 4.4 (v19). All you v14 resources will be used for v14-v18.
I'm trying to understand how the drawable folders in Android works. I found that in the resource folder in our project, it has the following folders:
res/drawable-ldpi/
res/drawable-ldpi-v8/
res/drawable-ldpi-v11/
res/drawable-mdpi/
res/drawable-mdpi-v8/
res/drawable-mdpi-v11/
res/drawable-hdpi/
res/drawable-hdpi-v8/
res/drawable-hdpi-v11/
res/drawable-xhdpi/
res/drawable-xhdpi-v8/
res/drawable-xhdpi-v11/
res/drawable-xxhdpi/
res/drawable-xxhdpi-v8/
res/drawable-xxhdpi-v11/
Can someone please educate me on how the fallback mechanism on these folders works? Also what does v8 and v11 mean?
From Android doc:
The API level supported by the device. For example, v1 for API level 1 (devices with Android 1.0 or higher) and v4 for API level 4 (devices with Android 1.6 or higher). See the Android API levels document for more information about these values.
-v8 and -v11 are API version but when android will determine the best match to use resource it will use them as "level" (and not strict api version number), e.g. with your project folders structure:
With device running Froyo (Android 2.2, API 8) with mdpi screen then resources will be taken from res/drawable-mdpi-v8/ folder
With device running Gingerbread (Android 2.3, API 10) with mdpi screen then resources will also be taken from res/drawable-mdpi-v8/ folder (because 8<10<11)
With device running Ice Cream Sandwich (Android 4.0, API 15) with mdpi screen then resources will also be taken from res/drawable-mdpi-v11/ folder (because 11<15)
--
Why default res folders are v-8, v-11,v-15... and not v-12,v-13 or v-16... ?
Because it was major releases of Android with changes on UI mechanism (e.g. Api 11 was the first Android optimized for tablets).
-v11 and -v8 are version qualifiers (you can read more here) for version 11 and 8 of android. If your app is running on one of them, then it tries to pick the drawable from the specific folder. If it is not in there, then it tries on the less specific. E.g. you are running and mdpi screen on Honeycomb, the first attempt is res/drawable-mdpi-v11/. If the drawable is not in there, it looks for it in res/drawable-mdpi/. The look up continues until the closest drawable to your configuration is found.
I'm having a little problem.
I've created a layout folder layout-v9 and in the layoutfolder I've got 2 layouts. In my ordinary layout folder I've got the same 2 layouts.
Now when running Android 4.4 he still takes the layout from the v9 folder.
How is this possible?
layout-v9 folder won't be used only by Android API 9, but by every Androd with API >= 9, it's why Android 4.4 (API 19) uses it.
Providing Resources
The API level supported by the device. For example, v1 for API level 1
(devices with Android 1.0 or higher) and v4 for API level 4 (devices
with Android 1.6 or higher). See the Android API levels document for
more information about these values.
EDIT:
How can I have a layout for just the v9 versions?
I don't know about other way using folders than also providing v10 folder, so API 9 will use v9 folder, and any higer API v10 folder.
In case of other problems, beside using folders, you may want to do some things related to API >= 10 in code
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
// API >= 10 stuff
}
Sorry for the newbie question. I'm developing Android app using Xamarin studio and MonoDroid.
If I'm choosing target platform v2.3 then I have support for devices running Andoird OS v2.3+
but... for devices running v2.3 I have the same design as for devices running v4.0.3:
https://dl.dropboxusercontent.com/u/19503836/android_api10.png
Only if I choose project target platform v4.0.3 then I get expected design but in this case I have no support for devices running v2.3:
https://dl.dropboxusercontent.com/u/19503836/android_api15.png
Is it possible to have different design style activated for different Android OS versions having target platform v2.3?
You can use different layouts for different android versions. Just make different folders for the layouts. Res/layout is for default layouts, Res/layout-v14 is for android 4.3 and above. Just look for the API version you need and add it to the folder name.
You can also use different styles per version the same way. The styles are defined in a XML on res/values, just specify the API version in the folder res/values-vXX.
By your example it seems that by default your IDE is already creating different styiles for different versions, so look for that folders on your project tree.
You have more info on Android Developer
I have a Android application using 2.1. I've gone ahead and created a drawable-xhdpi folder and put assets in it. I've set targetSdk=15, but the drawable in that folder is not being used. Is it not possible to support newer devices and keep an minimum sdk of 7?