Android - Fix screen orientation for 1 page only (

2019-01-18 23:18发布

I am having an issue with fixing the screen orientation for my index.html page only. I want to allow the app to rotate except on the home page. I understand that adding the following into you activity - android:screenOrientation="portrait" stops the screen from rotating.

However, I need to set this so it is page specific. I am using phonegap and therefore, need to stop my web view pages.

I tried calling the following activity within my manifest - com.phonegap.droidgap.index.html, however this did not work.

Could someone please advice me as to how I can define the fixed orientation for 1 page only?

Thanks in advance

2条回答
时光不老,我们不散
2楼-- · 2019-01-18 23:26

You can use this PhoneGap Plugin for Android:

https://github.com/champierre/pg-plugin-screen-orientation

And add to your index.html page onload:

navigator.screenOrientation.set('portrait');
查看更多
再贱就再见
3楼-- · 2019-01-18 23:26

You can set the screen orientation from you code using for example setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); see http://developer.android.com/reference/android/app/Activity.html#setRequestedOrientation%28int%29 . In the AndroidManifest.xml you can set it only as a global option.

查看更多
登录 后发表回答