如何创建只允许水平方向的应用程序?

发布于 2024-10-03 04:04:35 字数 145 浏览 0 评论 0原文

我目前正在为我学位的最后一年项目创建一款横向卷轴风格的游戏。

我只是想知道当手机处于水平方向显示时,即使手机处于垂直方向,您如何设计菜单?

即我希望用户知道游戏必须在手机水平方向上玩,并且希望菜单仅在水平方向上显示。

非常感谢。

I'm currently creating a side-scroller style game for my final year project for my degree.

I'm just wondering how you make the menu designed for when the phone is in horizontal orientation display, even when the phone is held in it's vertical orientation?

i.e. I want the user to know that the game has to be played with the phone in it's horizontal orientation and want the menu's to only display in the horizontal orientation.

Many thanks in advance.

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

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

发布评论

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

评论(3

荒芜了季节 2024-10-10 04:04:35

将以下属性添加到 AndroidManifest.xml 中的 Activity:

android:screenOrientation="landscape"

Add the following attribute to your activity in your AndroidManifest.xml:

android:screenOrientation="landscape"

情深缘浅 2024-10-10 04:04:35

呃,我没听清楚你的问题,
但如果您通过 xml 定义菜单,

请在 res 文件夹中创建一个新文件夹,命名

为布局更改:

layout_land

用于水平特定菜单:

 xml-land

用于水平特定可绘制对象:

drawable-land

并在那里定义菜单、布局和可绘制对象更改。

此外,你可以告诉 android 框架你想要处理旋转变化:
通过添加到您的清单(AndroidManifest.xml)活动子

android:configChanges="keyboardHidden|orientation"
android:screenOrientation="landscape"

注释您想要的内容。

干杯!

Well, I didn't get your question right,
but if you are defining your menu via xml

create a new folder in your res folder named

for layout changes:

layout_land

for horizontal specific menu:

 xml-land

for horizontal specific drawables:

drawable-land

and define your menu,layout and drawable changes there.

Further you can tell android framework that you want to handle rotation changes:
by adding to your manifest(AndroidManifest.xml) activity child

android:configChanges="keyboardHidden|orientation"
android:screenOrientation="landscape"

Comment exactly what you want.

Cheers!

恰似旧人归 2024-10-10 04:04:35

只是补充其他人的答案

有一些不同类型的景观,我认为最好的一种是:

android:screenOrientation="userLandscape"

因为它允许用户使用设备的传感器切换到景观或反向景观,或者用户可以根据需要阻止切换。

我发现删除用户的一些基本控件非常烦人,只有在确实必要时才应该使用。

如果您想查看其他可能的方向,请前往此处

Just complementing on other's answers

There are some different types of landscape and I think the best one is:

android:screenOrientation="userLandscape"

because it lets the user switch to landscape or reverse landscape using the device's sensor, or the user can block the swithing if he decides to.

I found that removing some basic controls of the user is quite annoying and should only be used if really necessary.

If you want to checkout other possible orientations just go here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文