Android:横向模式的备用布局xml

Bry*_*eld 120 resources layout android orientation android-layout

如何为横向设置一个布局,为纵向设置一个?当用户将手机侧向旋转时,我想假设额外的宽度并节省垂直空间.

mar*_*pet 214

默认情况下,布局/res/layout适用于纵向和横向.

如果你有例如

/res/layout/main.xml
Run Code Online (Sandbox Code Playgroud)

您可以添加新文件夹/res/layout-land,复制main.xml到其中并进行必要的调整.

取向

另请参阅http://www.androidpeople.com/android-portrait-amp-landscape-differeent-layoutshttp://www.devx.com/wireless/Article/40792/1954以获取更多选项.

  • 你不能使用任何其他词 (8认同)

Ree*_*ing 72

在当前版本的Android Studio(v1.0.2)中,您只需单击下面屏幕截图中显示的可视化编辑器中的按钮即可添加横向布局.选择"创建景观变化"

Android Studio添加横向布局

  • @NoniA.它应该检测手机何时切换到横向并自动从布局 - 土地呼叫. (2认同)

Dal*_*mas 43

除非您另行指定,否则/ res/layout中的布局将应用于纵向和横向.假设我们的主页有/res/layout/home.xml,我们希望它在2种布局类型中看起来不同.

  1. 创建文件夹/ res/layout-land(这里你将保留你的横向调整布局)
  2. 在那里复制home.xml
  3. 对它进行必要的改变

资源


Shi*_*hid 7

Fastest way for Android Studio 3.x.x and Android Studio 4.x.x

1.Go to the design tab of the activity layout

2.At the top you should press on the orientation for preview button, there is a option to create a landscape layout (check image), a new folder will be created as your xml layout file for that particular orientation

在此处输入图片说明