Android Studio: Creating landscape layouts

后端 未结 5 1641
囚心锁ツ
囚心锁ツ 2020-11-29 01:47

Until recently I used Eclipse, and in Eclipse I simply created a folder /res/layout-landscape and put alternate landscape layouts inside.

However, it seem in Android

5条回答
  •  没有蜡笔的小新
    2020-11-29 02:23

    The accepted answer is actually seriously outdated. In Android Studio 3.x.x, there is no need to create an extra layout folder (I am not sure this was necessary back then anyway).

    There is also no need to change the project scope from Android to Project as the accepted answer tells you to.

    There is also no need to edit any UI attributes and modes as the accepted answer says.

    There are just 2 steps:

    1) Open your base UI layout in DESIGN mode so that you see the actual GUI, such as buttons, icons etc. (do NOT open it as text, in the XML code view mode).

    2) Click the icon marked in the below screenshot and, from the menu, select Create Landscape Variation (marked in the screenshot as 'Click 2nd').

    Then, the Studio does all the job for you and it works like a charm. No need to add any extra code and no extra folders are created.

    Enjoy.

    Android Studio 3.1.4:

提交回复
热议问题