2

I'm working on a Phonegap app and have two simple requirements:

  1. Lock app orientation to portrait
  2. Prevent the device keyboard from changing the height of the window on Android

From what I've found, there are two preferences that can be added to the root config.xml file to enable these properties:

<preference name="orientation" value="portrait" />
<preference name="android-windowSoftInputMode" value="adjustNothing" />

However, I can't get either behavior to manifest no matter how I run the app; the browser allows landscape, and both the Phonegap Developer app and the compiled apk show landscape and height changes.

How do I ensure the changes in the config.xml get reflected in the builds? Are there any peculiarities with phonegap serve/build I should know about regarding this?

EDIT: It seems like the changes not being reflected was a weird quirk. Building again, the preferences work exactly as they should.

budjmt
  • 135
  • 1
  • 9
  • 1
    The config settings in config.xml will be reflected in the build once you build the platform. In case of Android, executing 'cordova build android' will reflect the changes in AndroidManifest.xml Also platform specific preferences should be placed inside respective platform tags. Eg: – Gandhi Jul 08 '16 at 05:41
  • 1
    And also i m not sure about adjustNothing value for android-windowSoftInputMode property as i dont see such value in the official documentation - https://developer.android.com/guide/topics/manifest/activity-element.html#wsoft Guess you gotta use adjustPan – Gandhi Jul 08 '16 at 05:45
  • @Gandhi I've noticed the lines do appear in the the manifest file, they just don't seem to have a visible effect. As for adjustNothing, I got the value from other answers where the config changes worked and the [lack of appearance in the documentation](https://code.google.com/p/android/issues/detail?id=69134) is apparently just a thing. I'll check if moving that tag to the android specific section works tomorrow and update, but the orientation is a different story. – budjmt Jul 08 '16 at 06:10
  • Check orientation on a device rather than browser. Also try using adjustPan instead of adjustNothing – Gandhi Jul 08 '16 at 06:12
  • It looks like it all works now on a compiled apk. In fact, I tested it with it both in the android preference list and where it originally was, and it worked both ways! It seems like it just wasn't transferring before for some unknown reason. The browser/app still doesn't exhibit the behavior, but natively it works fine. Thanks for the help @Gandhi! – budjmt Jul 08 '16 at 16:32
  • but the preference value and expoana makes sense. Should I post this as answer don't u think? – Gandhi Jul 08 '16 at 19:37
  • @Gandhi The preference value does make sense, though I'm not sure what you mean by expoana. Technically, the question relates to how the config gets built, so the first comment would be a valid answer. – budjmt Jul 08 '16 at 20:49
  • sorry that was a typo. I meant explanation.anyways posting first comment as u suggested – Gandhi Jul 09 '16 at 07:23

1 Answers1

0

The config settings in config.xml will be reflected in the build once you build the platform. In case of Android, executing cordova build android will reflect the changes in AndroidManifest.xml Also platform specific preferences should be placed inside respective platform tags. Eg: <platform name="android"> <allow-intent href="market:*" /> </platform>

And also i m not sure about adjustNothing value for android-windowSoftInputMode property as i dont see such value in the official documentation - https://developer.android.com/guide/topics/manifest/activity-element.html#wsoft Guess you gotta use adjustPan

Gandhi
  • 11,875
  • 4
  • 39
  • 63