Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the value for SoftInputMode

I am having some issues with a Phonegap app for Android with the soft keyboard.

  • If I set the SoftInputMode to adjustResize my content starts flickering when the keyboard shows/hides because of position:fixed and absolute.

  • If I set it to adjustPan it solves my flickering but I have an issue with a form where the keyboard covers my inputs and you can't scroll or click anywhere else to hide the keyboard.

  • This could be fixed by adding a height greater than 100% but I don't want to scroll the page if the keyboard is not visible.

  • One way I thought of solving it is to listen for url change and if it matches to my form page to set the mode to adjustResize otherwise to set it to adjustPan.

  • I would like to be able to know the current value and not set this value on every url change if there is no need for the change.

Other solutions are welcomed.

Here is my current code:

@Override
public void onPageFinished(WebView view, String url) {
   //Implement your code
   if(url.lastIndexOf("/pagewithform") != -1) {
      getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
   } else {
      getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
   }
   super.onPageFinished(view, url);
}
like image 561
TestersGonnaTest Avatar asked Jan 23 '14 12:01

TestersGonnaTest


1 Answers

Would this work?

getWindow().getAttributes().softInputMode
like image 167
Y2i Avatar answered Nov 15 '22 03:11

Y2i