How to use "adjustPan" and "adjustResize" together

Nasif Noorudeen picture Nasif Noorudeen · Jan 28, 2015 · Viewed 7.1k times · Source

I am facing a weired issue. i have two fragments in a single activity. One is a login Fragement . I have two edit text in this fragment. Some devices this filed is hiding by soft keyaboard i specified adjustPan in my manifest and this is working fine

When user clicking a button on LoginFragment i am opening another fragment named forgetpassword . This is a webview and url is loading from a remote server. But the textfield in html is hide by softkeyboard. So i tried using adjustResize and it is working fine. But my editText widget in loginfragment is hide by keyboard.

How can i achieve both flags in my activity. Please help me with this.

Answer

Lei Guo picture Lei Guo · Jan 28, 2015

You can solve your problem by setting adjustPan and adjustResize programmatically.

Use the following code to set ajustPan when the current Fragment is your LoginFragment:

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

And use the following code to set ajustResize when the current Fragment is your webview Fragment:

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