[英]Disable landscape orientation in Android Browser?
我知道有一种方法可以限制应用程序内的方向,但是网页代码(无论是HTML, CSS or JS
)中是否有办法将Web视图限制为仅Potrait?
If you are using a Webview inside an Activity you will restrict to portrait adding the property 如果您在“活动”中使用Webview,则只能使用纵向添加属性
android:screenOrientation
android:screenOrientation
to your Manifest.xml 到您的Manifest.xml
<activity android:name=".MyActivity"
android:label="Jorge´s Activity"
android:screenOrientation="portrait">
No, there isn't. 不,没有。 That kind of control is on Android's end, not the web page it's displaying.
这种控件位于Android的末端,而不是其显示的网页。
You can choose to show a message telling the user to turn their phone if the orientation is not right. 如果方向不正确,您可以选择显示一条消息,告诉用户转动手机。
window.orientation
will tell you the orientation of the device. window.orientation
将告诉您设备的方向。 0 is upright, 90 is landscape. 0是直立的,90是风景。
尝试
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.