javascript - 纵向?

标签 javascript mobile cordova screen-orientation

如何将我的 phonegap 应用程序的方向锁定为纵向?

我当前的 config.xml正在使用此首选项:

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

但这没有什么区别,我仍然可以通过旋转我的移动测试设备来在两个方向上定位我的应用程序。

此外,如果您知道一个活跃的 phonegap/cordova 社区,您能否发布一个链接?

最佳答案

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

android:screenOrientation="portrait"

到 platforms/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>

成为

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

如果您需要其他肖像变体,请注意这一点。来自:http://developer.android.com/guide/topics/manifest/activity-element.html

你可以使用 reversePortrait 或 sensorPortrait

关于javascript - 纵向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20884724/

相关文章:

javascript - 当元素被移除时,事件监听器会发生什么?

javascript - 从 mvc web api httpresponse 生成 csv 并通过 angularjs 接收它以供下载

asp.net-mvc - 在 Azure 上获取 'you do not have permission to view this directory or page'

javascript - jQuery Ajax 在 cordova iOS 应用程序上发送之前触发成功

javascript - 将关联数组添加到 jQuery 对象作为属性

javascript - 这个 Prototype 到 JQuery 的端口是否正确?

手机号码确认

css - 如何响应式地将图像高度缩放到设备的高度

ios - Cordova Visual Studio 2015 RC 社区 : Remote Device iOS

ios - 构建平台之一时出错 : Error code 65 for command: xcodebuild with args: -xcconfig | cordova-plugin-purchase build fails