Portrait Orientation?

醉酒当歌 提交于 2020-01-02 07:23:09

问题


How do I lock the orientation of my phonegap application to portrait?

My current config.xml is using this preference:

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

However it makes no difference and I can still orientate my application in both orientations by rotating my mobile test device.

Also if you know of a an active phonegap/cordova community could you please post a link?


回答1:


If you are working with Android you can add

android:screenOrientation="portrait"

to the main activity tag in the platforms/android/AndroidManifest.xml file.

So

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

becomes

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

Just another note in case you want other portrait variations. From: http://developer.android.com/guide/topics/manifest/activity-element.html

You could use reversePortrait or sensorPortrait



来源:https://stackoverflow.com/questions/20884724/portrait-orientation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!