To top on Eu Vid's answer, I wish to point out that Cordova 6.4.0 and above has support for <edit-config />
which we can use to modify AndroidManifest.xml
.
First you will need to add the android namespace attribute. In your config.xml
, add a new attribute xmlns:android="http://schemas.android.com/apk/res/android"
to <widget />
. Your widget block should look something like this:
<widget
id="com.my.app"
version="0.0.1"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">
Now add the following code inside <widget />
:
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
<activity android:configChanges="orientation|keyboardHidden" android:windowSoftInputMode="adjustPan" />
</edit-config>
Now when you call cordova platform add android
, the AndroidManifest.xml
will be generated with the settings above.
Note:
- The code above does not overwrite the
<activity>
block but merges with it; it will only replace the specified xml attributes.
- If you already called
cordova platform add android
beforehand, you can remove it by entering cordova platform rm android
first before adding it again.