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

雨燕双飞 提交于 2019-12-01 03:53:24

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.

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!