简体   繁体   English

Android-修复仅1页的屏幕方向(phonegap)

[英]Android - Fix screen orientation for 1 page only (phonegap)

I am having an issue with fixing the screen orientation for my index.html page only. 我仅在为index.html页面固定屏幕方向时遇到问题。 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. 我了解向您的活动添加以下内容-android:screenOrientation =“ portrait”可以阻止屏幕旋转。

However, I need to set this so it is page specific. 但是,我需要设置它,使其特定于页面。 I am using phonegap and therefore, need to stop my web view pages. 我正在使用phonegap,因此需要停止我的Web视图页面。

I tried calling the following activity within my manifest - com.phonegap.droidgap.index.html, however this did not work. 我尝试在清单中调用以下活动-com.phonegap.droidgap.index.html,但是这不起作用。

Could someone please advice me as to how I can define the fixed orientation for 1 page only? 有人可以建议我仅如何定义一页的固定方向吗?

Thanks in advance 提前致谢

You can use this PhoneGap Plugin for Android: 您可以使用以下适用于Android的PhoneGap插件:

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

And add to your index.html page onload: 并添加到您的index.html页面onload:

navigator.screenOrientation.set('portrait');

You can set the screen orientation from you code using for example setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 您可以使用例如setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);从代码中设置屏幕方向setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); see http://developer.android.com/reference/android/app/Activity.html#setRequestedOrientation%28int%29 . 请参阅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. 在AndroidManifest.xml中,您只能将其设置为全局选项。

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

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