如何创建只允许水平方向的应用程序?
我目前正在为我学位的最后一年项目创建一款横向卷轴风格的游戏。
我只是想知道当手机处于水平方向显示时,即使手机处于垂直方向,您如何设计菜单?
即我希望用户知道游戏必须在手机水平方向上玩,并且希望菜单仅在水平方向上显示。
非常感谢。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将以下属性添加到 AndroidManifest.xml 中的 Activity:
android:screenOrientation="landscape"
Add the following attribute to your activity in your AndroidManifest.xml:
android:screenOrientation="landscape"
呃,我没听清楚你的问题,
但如果您通过 xml 定义菜单,
请在 res 文件夹中创建一个新文件夹,命名
为布局更改:
用于水平特定菜单:
用于水平特定可绘制对象:
并在那里定义菜单、布局和可绘制对象更改。
此外,你可以告诉 android 框架你想要处理旋转变化:
通过添加到您的清单(AndroidManifest.xml)活动子
注释您想要的内容。
干杯!
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:
for horizontal specific menu:
for horizontal specific drawables:
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
Comment exactly what you want.
Cheers!
只是补充其他人的答案
有一些不同类型的景观,我认为最好的一种是:
因为它允许用户使用设备的传感器切换到景观或反向景观,或者用户可以根据需要阻止切换。
我发现删除用户的一些基本控件非常烦人,只有在确实必要时才应该使用。
如果您想查看其他可能的方向,请前往此处
Just complementing on other's answers
There are some different types of landscape and I think the best one is:
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