Android layout folders: layout, layout-port, layout-land

后端 未结 3 1438
刺人心
刺人心 2020-11-27 03:12

I\'m not sure to have understood well the role played by the several Android /res/layout folders.

layout: general layouts

lay

相关标签:
3条回答
  • 2020-11-27 04:00

    Create folder in res layout-land or layout-port

    layout-port: layout for widget that must change for portrait orientation

    layout-land: layout for widget that must change for landscape orientation

    0 讨论(0)
  • 2020-11-27 04:09

    If you put home.xml in layout-port folder, when your device is in portrait orientation it will use the file: layout-port/home.xml.

    If you put home.xml in layout-land folder, when your device in landscape orientation it will use the file: layout-land/home.xml.

    Meaning for different orientation modes like portrait and landscape... we use two home.xml files; one in layout-port and the other in layout-land. If on the other hand you want to use the same layout file for both, you can just put home.xml in the layout folder and remove it from layout-land and layout-port.

    0 讨论(0)
  • 2020-11-27 04:14

    If you are in landscape or portrait Android looks for the layout file in either the -port or -land directory first, if it's not found then it falls back to the default layout directory.

    You can read about providing alternative resources here. There are many more options than just land and port.

    0 讨论(0)
提交回复
热议问题