Adapt layout to Android platform or API level

后端 未结 3 1500
滥情空心
滥情空心 2020-12-05 01:48

For the application I am currently developing, I need to adapt the layout of the different activities to the user\'s Android API level.

Is there a way to do this?

3条回答
  •  一向
    一向 (楼主)
    2020-12-05 02:42

    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/mylayout.xml       (Default)
    res/layout-v4/mylayout.xml    (Android 1.6)
    res/layout-v11/mylayout.xml   (Android 3.0)
    

    and so on, where vN is the API level. The specific API levels can be found on this page.

提交回复
热议问题