2014-01-19 57 views
7

我使用科尔多瓦3.3.0与我的银河S3(运行最新Cyanogenmod)来测试我正在工作的应用程序;我需要应用程序屏幕保持“肖像”模式,即使用户旋转设备也会被锁定。无论我尝试了什么或者我遵循的教程,该应用都忽略了锁定屏幕的首选项。我究竟做错了什么?科尔多瓦忽略屏幕方向锁

这里是我的config.xml:

<?xml version='1.0' encoding='utf-8'?> 
<widget id="com.numediaweb.test" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> 
    <name>Test</name> 
    <description> 
     Test.</description> 
    <author href="http://test.com" email="[email protected]"> 
     me 
    </author> 
    <content src="index.html" /> 
    <access origin="*" /> 
    <preference name="orientation" value="portrait" /> 
    <preference name="fullscreen" value="true" /> 
    <preference name="SplashScreen" value="splash" /> 
    <preference name="SplashScreenDelay" value="3000" /> 
</widget> 

回答

12

我刚刚发现了一个有趣的answer我张贴的问题(在相关部件右)之后;这是一个bug in Cordova并修复它,你要么编辑AndroidManifest.xml到类似的东西;

<activity android:screenOrientation="portrait" android:configChanges=... 

或使用plugin

FI更喜欢编辑清单,因为它很容易。

+1

缺点是当你删除/重建你的Android平台;你必须再次添加更改:(插件的另一件事是,如果你想开始预先锁定的科尔多瓦应用程序,你必须编辑onCreate()活动。 – numediaweb

+0

提供的插件已弃用,请使用以下代码:http: //stackoverflow.com/a/32405384/1848600 – Gajotres

14

固定在科尔多瓦3.4.1。 现在偏好方向的作品!

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

我在3.5.0我不认为它是固定的。https://issues.apache.org/jira/browse/CB-6182 –

1

的解决方法是编辑Android清单如下:

<application 
      android:icon="@drawable/icon" 
      android:label="@string/app_name" > 
      <activity 
       android:name=".AppName" 
       android:configChanges="orientation|keyboardHidden|screenSize" 
       android:label="@string/app_name" 
       android:launchMode="singleTask" 
       android:screenOrientation="unspecified" 
       android:theme="@android:style/Theme.Translucent.NoTitleBar" > 

与不特定的Android选择设备的正确方向。 es。智能手机只是肖像,但平板电脑是肖像和风景