Android:当屏幕小于 x 时禁用屏幕旋转
有人知道当屏幕小于(例如)480px 时如何在 Android 应用程序中禁用屏幕旋转吗? 我正在使用 PhoneGap 构建应用程序,该应用程序将针对平板电脑设备,但也可以在智能手机上运行。不幸的是,只有当应用程序以横向显示时,应用程序才能正确显示......
Anyone know how can I disable screen rotation in my Android app when screen is smaller than (for example) 480px?
I'm building app using phonegap witch will be targeted to tablet devices, but it's also possible to run it on smart-phones. Unfortunately application is only displayed properly when app is displayed in landscape orientation...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许是一个“if”控制的
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
在 onCreate 函数中?
Maybe an 'if' controlled
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
in the onCreate function?
做到了! :)
以下是方法(不言自明):
以及一些导入:
Did it! :)
Here is how (self explanatory):
and few imports:
结合@Howard Hodson的解决方案和这个线程如何使用代码确定设备屏幕尺寸类别(小、正常、大、超大)?
我使用以下代码:
combining the solution of @Howard Hodson and in this thread How to determine device screen size category (small, normal, large, xlarge) using code?
I use this code: