Robert Greville
Robert Greville

Reputation: 11

Disable landscape orientation in Android Browser?

I know there is a way to 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?

Upvotes: 1

Views: 2264

Answers (4)

user1087919
user1087919

Reputation:

Try

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

Upvotes: 0

gnur
gnur

Reputation: 4733

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.

Upvotes: 0

Jorgesys
Jorgesys

Reputation: 126445

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">

Upvotes: 1

goncalossilva
goncalossilva

Reputation: 1860

No, there isn't. That kind of control is on Android's end, not the web page it's displaying.

Upvotes: 0

Related Questions