androidhtmlcsscordovaiscroll

input field hidden when soft keyboard appears in phonegap


Creating a mobile application using Phonegap 3.6.3 for Android and iOS. The problem is only for Android, as iOS acts as I would like it to.

When I click on an input text field, or a textarea, a soft keyboard appears. It covers these elements sometimes.

The pages are placed within a iScroll, right at the bottom, and another absolute-placed div, thus I cannot scroll to either of these once the screen pops up. I suspect I have to change the webview to be smaller when the keyboard comes up. However, after trying many things, it isn't working.

config.xml

    <preference name="permissions" value="none" />
    <preference name="phonegap-version" value="3.5.0" />
    <preference name="orientation" value="default" />
    <preference name="target-device" value="universal" />
    <preference name="fullscreen" value="false" />
    <preference name="webviewbounce" value="true" />
    <preference name="prerendered-icon" value="false" />
    <preference name="stay-in-webview" value="false" />
    <preference name="ios-statusbarstyle" value="black-opaque" />
    <preference name="detect-data-types" value="true" />
    <preference name="exit-on-suspend" value="false" />
    <preference name="show-splash-screen-spinner" value="false" />
    <preference name="auto-hide-splash-screen" value="false" />
    <preference name="disable-cursor" value="false" />
    <preference name="android-minSdkVersion" value="13" />
    <preference name="android-windowSoftInputMode" value="adjustResize|stateHidden" />
    <preference name="android-installLocation" value="auto" />
    <preference name="SplashScreen" value="splash" />

(have tried many different values for android-windowSoftInputMode, as per example below)

    <preference name="android-windowSoftInputMode" value="stateVisible|adjustResize|adjustPan" />

head of web page

    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />

(yes, I've tried many other things too)

anything else you may perceive as relevant, please let me know. Unfortunately, I'm not at liberty to share too much of the code, but from my understanding that's all we need to worry about.

Thanks,


Solution

  • Remove this line from config.xml

    <preference name="android-windowSoftInputMode" value="adjustResize|stateHidden" />
    

    And change the line in 'head of web page' to

    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />