Android+PhoneGap: android:windowSoftInputMode doesn't seem to work

后端 未结 3 515
小蘑菇
小蘑菇 2021-01-12 04:03

I\'m developing a PhoneGap-based application and I googled much about how to make my webview adjust its height when virtual keyboard appears, or at least get height of the v

相关标签:
3条回答
  • 2021-01-12 04:32

    I found I needed to to 3 things to resolve this issue, and prevent the actionBar from hiding itself, from scrolling out of view when the soft keyboard was brought up.

    1) In AndroidManifest.xml, in the activity in question, I needed the line:

    android:windowSoftInputMode="adjustResize"
    

    The original problem is that adjustPan was present in the line above. At first, just the change above fixed the problem.

    The project I am on uses fragments. In the onCreateView method, a different fragment had the line:

    getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    

    That line, unfortunately, overrode the adjustResize parameter in the Application manifest, and after that other fragment was displayed, the fragment that I fixed broke again. So, to fix the new break, I did 2 additional things.

    2) I deleted the SOFT_INPUT_ADJUST_PAN line from the onCreateView method of that other fragment, because it did not need that line anyway.

    3) In the onCreateView method of the fragment with which I am primarily concerned, I added the line:

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

    Actually, doing either of items 2 or 3 would solve the problem. I did both to be thorough.

    0 讨论(0)
  • 2021-01-12 04:50

    windowSoftInputMode="adjustResize" does not work if your app is in fullscreen mode (setting fullscreen to true in config.xml). It is Android's issue not Cordova. the issue CB-4404 was filed in Cordova bug tracker for months but recently it turns out that it is working as intended on Android bug tracker.

    I solved the problem by setting fullscreen to false since it wasn't a problem for my app not to go fullscreen.

    0 讨论(0)
  • 2021-01-12 04:50

    either you can set this property in android.manifest explicitly to "adjustNothing" then you do not need to set "fullscreen" mode to false. but you have to update it every time you update/add android platform.

    0 讨论(0)
提交回复
热议问题