Textbox hidden below keyboard in Android webview

2019-01-10 12:43发布

I have created a simple iPhone/Android app, containing a normal webview. This webview calls my website.

On my website there are several forms with input type=text or textarea. I have a problem with those when they are at the bottom of the page!

1) In my iPhone app, the keyboard will automatically appear and push the textbox to the visible area of the phone screen. So there is nothing to do.

2) But in my Android app the textbox will stay at the same place and is eventually hidden by my keyboard. So the only option users have is to type "blind".

How can I fix this? Did anyone else meet this problem?

7条回答
闹够了就滚
2楼-- · 2019-01-10 12:56

I was getting crazy nothing works android:windowSoftInputMode="adjustResize" may help but be sure to have your app not in full screen.

Removing full screen for my app solved the problem with the layout resize with softkeyboard.

<item name="android:windowFullscreen">false</item>
查看更多
3楼-- · 2019-01-10 12:58

Few things I learnt while solving this issue --- 1. Theme style should not contain Fullscreen True 2. Add android:windowSoftInputMode="adjustResize" 3. Remove android:scrollbars="none" is any.. . Cheers!

查看更多
Evening l夕情丶
4楼-- · 2019-01-10 13:01

This would work:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

查看更多
Anthone
5楼-- · 2019-01-10 13:06

Beware that apart from the suggest answers

android:windowSoftInputMode="adjustResize"

Is not working when you are in immersive mode

查看更多
Viruses.
6楼-- · 2019-01-10 13:07

This is how I solved the problem. As Venky said, you have to add

android:windowSoftInputMode="adjustResize"

to your tag in the AndroidManifest.xml file. But in our case, it wasn't enough. Make sure you do this as well with your views, webviews etc. Then we finally made it work.

查看更多
倾城 Initia
7楼-- · 2019-01-10 13:08

Yeah, had the same problem working with Webview, mine was with input filed on modal. Textfield didn't "focus" above the keyboard. The solution was to delay the function call. Hope someone finds this usefull.

   $("body").on("click", ".jstree-search-input", function () {  

    setTimeout(function(){ 
        androidScroll(); 
    }, 500);
    });

As you can see it's used for jstree input...

   function androidScroll() {
    // Webview focus call (pushes the modal over keyboard)
        $('.control-sidebar-open ').scrollTop($('.control-sidebar-open ')[0].scrollHeight);

}

查看更多
登录 后发表回答