Jay*_*ren 136 android landscape portrait orientation
我已经看到了能够为一个活动指定两个单独的布局xml文件的引用,一个用于Portrait,一个用于Landscape.我没有找到任何有关如何做到这一点的信息.如何为每个活动指定哪个xml文件是纵向布局,哪个是横向布局?
是否也可以为不同的屏幕尺寸指定不同的布局?如果是这样,这是怎么做到的?
Mar*_*k B 198
创建一个layout-land
目录,并将布局XML文件的横向版本放在该目录中.
Sil*_*ini 59
您只需根据方向和分辨率将其放在具有不同名称的单独文件夹下,设备将自动为其屏幕设置选择正确的文件夹
更多信息:
http://developer.android.com/guide/practices/screens_support.html
在"屏幕大小和密度的资源目录限定符"下
Ami*_*imi 25
适合老鼠爱好者!我说右键单击resources文件夹Add new resource file
,然后从Available qualifiers中选择orientation
:
但是你仍然可以通过添加子文件夹"layout-land"来手动完成
"你的项目方向\程序\ SRC \主\ RES"
从那时起,此子文件夹下的任何layout.xml文件将仅自动用于横向模式.
使用"layout-port"作为纵向模式.
Rob*_*Qiu 20
只是提醒:
如果已定义,orientation
则从android:configChanges
清单xml
文件中的活动属性中删除:
android:configChanges="orientation|screenLayout|screenSize"
Run Code Online (Sandbox Code Playgroud)
Shi*_*hid 18
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
我认为最新 Android 版本中最简单的方法是进入 XML(而不是文本)的设计模式。
然后从菜单中选择选项 - 创建景观变化。这将在几秒钟内轻松创建一个横向 xml。最新的 Android Studio 版本允许您立即创建横向视图。
我希望这对你有用。
归档时间: |
|
查看次数: |
160437 次 |
最近记录: |