【问题标题】:Change in layout with change in orientation布局随着方向的变化而变化
【发布时间】:2013-09-12 06:47:26
【问题描述】:
嗨,在我的 android 应用程序中,垂直方向的按钮是否有可能变为水平方向的选项卡。所以它们更适合平板电脑?
【问题讨论】:
-
-
-
您可以查看link 了解有关平板电脑布局的更多详细信息
标签:
android
android-layout
android-intent
android-emulator
【解决方案1】:
一种方法是创建2个名为layout-land和layout-port的文件夹,编写2个同名的不同xml并将它们放在layout-land和layout-port中
例如,如果你有一个 home.xml
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.
【解决方案2】:
您必须为纵向和横向模式创建单独的 XML 文件并将其放置在不同的目录中。设备会自动选择正确的。可以使用如下目录结构
res/layout/my_layout.xml
res/layout-land/my_layout.xml
更多详情请阅读doc。
【解决方案3】:
是的,这绝对是可能的。
你检查过这个one吗?基本上它在你的 Android 项目中使用资源。您可以创建以下文件夹:
res/layout/ //portrait
res/layout-land/ //landscape
根据您的需要,有一个名称相同但内容不同的布局。
【解决方案4】:
对于 7 英寸平板电脑:- 在 res/layout-sw600dp-port 中创建一个新文件夹以用于纵向模式
和 res/layout-sw600dp-land 用于横向模式
对于 10 英寸平板电脑:-在 res/layout-sw720dp-port 中创建一个新文件夹以用于纵向模式
和 res/layout-sw720dp-land 用于横向模式
对于最大 5 英寸屏幕的手机布局,只需在布局文件夹中设计您的屏幕
希望这对你有帮助
!!快乐编码!!