Search code examples
androidalarmandroid-2.3-gingerbread

Layout according to android version


i am trying to make a alarm clock, the GlowPadView in the newer android versions it quite good looking and i was planning to use that in my application, but at the same time i also want to support 2.3.3(Gingerbread) which still has a major chunk of phones. So i was wondering if there is a way that i can check the android version the phone is running and show the layout according to that. If the phone is running API 11 + the layout shows GlowPadView otherwise it shows basic swipe views from the Gingerbread stock alarm application.

To check the android version Build.VERSION_CODES can be used

android.os.Build.VERSION.SDK_INT;

Solution

  • So i was wondering if there is a way that i can check the android version the phone is running and show the layout according to that.

    Create separate directories, such as res/layout/ and res/layout-v11/. Have the same-named layout resource in each (e.g., foo.xml), and put the GlowPadView in the foo.xml that you place in res/layout-v11/.