Phonegap Android keyboard covers input elements scrolling is disabled

前端 未结 10 1557
夕颜
夕颜 2020-12-15 07:12

I\'ve tried many different solutions and nothing is quite what I want. What I want is for the keyboard to show on top of the content (keeping the content the same size) whi

10条回答
  •  悲&欢浪女
    2020-12-15 07:32

    I have the most efficient solution to scroll into input automatically and make it visible. First you need to add the ionic keyboard plugin (works on any cordova project) because the eventlistener 'showkeyboard' does not work now.

    cordova plugin add ionic-plugin-keyboard --save
    

    Then on your event handler of 'keyboardshow' event add the following code:

    window.addEventListener('native.keyboardshow', function(e){ 
        setTimeout(function() {
            document.activeElement.scrollIntoViewIfNeeded();
        }, 100);
    });
    

    P.S: This is supported only on Android (Chrome) and Safari. :D

提交回复
热议问题