繁体   English   中英

禁用Android浏览器中的横向方向?

[英]Disable landscape orientation in Android Browser?

我知道有一种方法可以限制应用程序内的方向,但是网页代码(无论是HTML, CSS or JS )中是否有办法将Web视图限制为仅Potrait?

如果您在“活动”中使用Webview,则只能使用纵向添加属性

android:screenOrientation

到您的Manifest.xml

 <activity android:name=".MyActivity"
              android:label="Jorge´s Activity"
              android:screenOrientation="portrait">

不,没有。 这种控件位于Android的末端,而不是其显示的网页。

如果方向不正确,您可以选择显示一条消息,告诉用户转动手机。 window.orientation将告诉您设备的方向。 0是直立的,90是风景。

尝试

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM