I know there is a way t开发者_如何学Co restrict the orientation within an app, but is there a way in code of a web page (whether it be HTML, CSS or JS
) to restrict the web view to only potrait?
If you are using a Webview inside an Activity you will restrict to portrait adding the property
android:screenOrientation
to your 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.
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. 0 is upright, 90 is landscape.
Try
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
精彩评论