android 如何处理手机屏幕方向

发布于 2024-11-15 21:05:56 字数 249 浏览 3 评论 0原文

我想知道如何处理移动屏幕方向意味着在 Android 移动设备中如果我将移动设备设置为水平,那么它的布局也是水平的,当我将其变为垂直时,它的布局将变为垂直..但是当我将水平设置为水平时,我的 UI 就会发生变化与我不同..

1)有什么方法可以让当我使其水平时,我的用户界面会根据高度和宽度自动设置。 我的

2)第二个问题是,如果我不想在使其水平时改变方向,意味着如果我使移动水平,那么它的方向也不会改变并且保持不变。

i want to know how to handle mobile screen orientation means in android mobile if i make the mobile horizotal then it's layout also be horizontol and when i turns it to verical then it's layout become vertical..but when i make horizontol then my UI becomes change and unlike to me..

1) so is there any way so that when i make it horizontol then my UI automatically set according to that heiht and width.
and my

2) second qus is that if i not want to change the orientation when i make it horizontol means if i make mobile horizontol then also its orientation will not change and it remains same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

恰似旧人归 2024-11-22 21:05:56

您应该有横向和纵向两种布局,并将您的landscapelayout 放入layout-land 并将protrailayout 放入layout 文件夹。 Android 会自动为您完成剩下的事情。

如果您处于横向或纵向,Android 首先在 -port 或 -land 目录中查找布局文件,如果未找到,则返回到默认布局目录。

你可以在这里阅读它..http://developer.android.com/指南/主题/资源/providing-resources.html

You should have two layout for both Landscape and Potrait and put your landscapelayout to layout-land and protrailayout to layout folder . Android will automatically do the rest of the things for you .

if you are in landscape or portrait Android looks for the layout file in either the -port or -land directory first, if it's not found then it falls back to the default layout directory.

you can read it here..http://developer.android.com/guide/topics/resources/providing-resources.html

很快妥协 2024-11-22 21:05:56

将其添加到您的活动的清单文件中,以获得您想要的活动的固定方向,

android:screenOrientation="portrait"

例如

<activity android:name=".Settings" android:label="@string/app_name" android:screenOrientation="portrait">

Add this in your Manifest file in your activity for the fixed orientation you want for your Activity

android:screenOrientation="portrait"

like

<activity android:name=".Settings" android:label="@string/app_name" android:screenOrientation="portrait">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文