[英]Change in layout with change in orientation
嗨,在我的android应用程序中,垂直方向的按钮可能会变为水平方向的标签。 因此,它们更适合平板电脑吗?
一种方法是创建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.
您必须为纵向和横向模式创建单独的XML文件,并将其放置在不同的目录中。 设备将自动选择正确的设备。 您可以使用以下目录结构
res/layout/my_layout.xml
res/layout-land/my_layout.xml
有关更多详细信息,请阅读此文档 。
是的,绝对有可能。
你检查这个了吗? 基本上,它使用的是Android项目中的资源。 您可以创建以下文件夹:
res/layout/ //portrait
res/layout-land/ //landscape
根据您的需要,使用具有相同名称但内容不同的布局。
对于7英寸平板电脑:-在纵向模式下在res / layout-sw600dp-port中创建一个新文件夹,在横向模式下在res / layout-sw600dp-land中创建一个新文件夹
10英寸平板电脑:-在纵向模式下在res / layout-sw720dp-port中创建一个新文件夹,在横向模式下在res / layout-sw720dp-land中创建一个新文件夹
适用于5英寸以下屏幕的电话布局,只需在布局文件夹中设计屏幕
希望对您有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.