Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating an Android application that supports multiple API levels

Tags:

android

I am going to create an Android application that supports multiple API levels. I searched the Android Developers website and learned that this is done as follows:

if (android.os.Build.VERSION.SDK_INT >= 11) 
{
  // Use APIs supported by API level 11 (Android 3.0) and up
} 
else 
{
  // Do something different to support older versions
}

The above is used in Java files, but what about XML files? I am using some Android 4.0 tags.

I am an iOS developer, too. In iOS, I always design UIs programmetically. Which is better in Android applications: creating applications programmatically, like I do for iOS applications, or by using XML files.

Android UI design is not good like iOS UI design is.

like image 209
SathishKumarEro Avatar asked May 29 '26 02:05

SathishKumarEro


1 Answers

You can have different subfolders in your res directory such as layout-v11, layout-v14 in addition to your layout folder. then if you are running, say, API 14, your app will frist try taking needed xml files from layout-v14, only then from layout directory. The same applies to other folders under the res directory.

like image 107
Alexander Kulyakhtin Avatar answered May 31 '26 15:05

Alexander Kulyakhtin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!