Abdul Sadik Yalcin
Abdul Sadik Yalcin

Reputation: 1822

Cordova android - Keyboard covering input fields

I know this has been asked number of times but none of the answered provide a solution.

<preference name="fullscreen" value="false" /> this isn't really a fix because I want the app to be fullscreen.

Config file options doesn't seem to do anything. I have tried:

android:windowSoftInputMode="adjustPan"
android:windowSoftInputMode="adjustResize"
android:windowSoftInputMode="adjustResize|stateHidden"

Scroll offset won't work either since there is no space to scroll.

$('.myinput').focus(function(e) {
    var container = $('.container'),
    scrollTo = $('.myinput');

    setTimeout((function() {
        container.animate({
            scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop()
        });
    }), 500);
});

screencast

Upvotes: 2

Views: 1350

Answers (1)

Jagdeesh
Jagdeesh

Reputation: 119

Please install:

cordova plugin add ionic-plugin-keyboard --save

and then do cordova prepare to load this new plugin in your www folder.

document.addEventListener('deviceready', function(e){
    window.addEventListener('native.keyboardshow', function () {
            cordova.plugins.Keyboard.disableScroll(true);
        });
});

or you can try this javascript function

<script>
      setInterval(function(){
      if( document.body.className.match('keyboard-open') ) {
      document.getElementById("messagearea").style.marginBottom="100px";
      }
                  else{
                     document.getElementById("messagearea").style.marginBottom="0px";
                  }

                  }, 1000);

  </script>

Upvotes: 1

Related Questions