Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine Layout files for multiple version numbers

Tags:

android

layout

All I have a different layout files for different versions of android like layout-v13 , but I noticed that the files are the same for newer versions of android (API 11-16). Is there a way to group them together as something like layout-v11,12,13,14,15,16? Thanks for your time!

like image 228
ninge Avatar asked Jul 02 '12 23:07

ninge


2 Answers

If what you're trying to do is show a different layout depending on which API version is available on the device, you want to use configuration qualifiers. The specifics for alternative resources are also documented.

The most basic way to do it is to create a layout folder for each API level you want to use, formatted as follows:

res/layout/layout.xml       (Default)
res/layout-v4/layout.xml    (Android 1.6 and higher)
res/layout-v11/layout.xml   (Android 3.0 and higher)

From Android official documentation enter image description here

In your case layout-v11 this will be used by devices running Android 3.0 Honeycomb and above

like image 52
K_Anas Avatar answered Oct 04 '22 05:10

K_Anas


layout-v11 will be used by all devices running Android 3.0 and above. You should only break up the folders (i.e. layout-v11, layout-v12, etc.) if devices running the specific version require a different layout.

like image 40
Alex Lockwood Avatar answered Oct 04 '22 03:10

Alex Lockwood