纵向?

Jos*_*ett 3 javascript mobile screen-orientation cordova

如何将手机屏幕应用程序的方向锁定为肖像?

我目前config.xml正在使用此偏好:

<preference name="orientation" value="portrait"/>

然而,它没有任何区别,我仍然可以通过旋转我的移动测试设备来定位我的应用程序在两个方向.

另外,如果你知道一个活跃的phonegap/cordova社区,你可以发一个链接吗?

Dus*_*son 9

如果您使用Android,则可以添加

android:screenOrientation="portrait"
Run Code Online (Sandbox Code Playgroud)

到platform/android/AndroidManifest.xml文件中的主活动标记.

所以

<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="inappbrowser" android:theme="@android:style/Theme.Black.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

<activity android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="inappbrowser" android:theme="@android:style/Theme.Black.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

如果您想要其他肖像变化,请另外注意.来自:http://developer.android.com/guide/topics/manifest/activity-element.html

您可以使用reversePortrait或sensorPortrait