Android: alternate layout xml for landscape mode

后端 未结 6 599
故里飘歌
故里飘歌 2020-11-22 08:54

How can I have one layout for landscape and one for portrait? I want to assume extra width and conserve vertical space when the user rotates the phone over sideways.

6条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 09:18

    The layouts in /res/layout are applied to both portrait and landscape, unless you specify otherwise. Let’s assume we have /res/layout/home.xml for our homepage and we want it to look differently in the 2 layout types.

    1. create folder /res/layout-land (here you will keep your landscape adjusted layouts)
    2. copy home.xml there
    3. make necessary changes to it

    Source

提交回复
热议问题