input field hidden when soft keyboard appears in phonegap

后端 未结 8 975
失恋的感觉
失恋的感觉 2020-12-03 12:41

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

8条回答
  •  一个人的身影
    2020-12-03 13:36

    I have the most efficient solution to scroll into input automatically and make it visible. First you need to add the keyboard plugin(cordova plugin add com.ionic.keyboard) as mentioned by @Fedir. 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

提交回复
热议问题