1

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.

Nasif Noorudeen
  • 143
  • 2
  • 15

3 Answers3

1

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);
Lei Guo
  • 2,550
  • 1
  • 17
  • 22
  • When placing adjust pan in the manifest this works correctly but when trying to place both flags in a fragment with flags like this getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); it does not. – Doug Ray Nov 04 '16 at 21:21
  • @DougRay They should not be combined together, see https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#SOFT_INPUT_ADJUST_PAN – Lei Guo Nov 05 '16 at 07:06
0

adjustResizeandadjustPan can not be combined with each other. They are different default actions for preventing soft input from covering input field. As indicated in the comment for WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN

    /** Adjustment option for {@link #softInputMode}: set to allow the
     * window to be resized when an input
     * method is shown, so that its contents are not covered by the input
     * method.  This can <em>not</em> be combined with
     * {@link #SOFT_INPUT_ADJUST_PAN}; if
     * neither of these are set, then the system will try to pick one or
     * the other depending on the contents of the window. If the window's
     * layout parameter flags include {@link #FLAG_FULLSCREEN}, this
     * value for {@link #softInputMode} will be ignored; the window will
     * not resize, but will stay fullscreen.
     */
    public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
DYS
  • 2,826
  • 2
  • 23
  • 34
-1

You can solve your problem by setting adjustPan and adjustResize programmatically. Also, in the listview add android:transcriptMode="alwaysScroll"

haihui
  • 1,075
  • 1
  • 18
  • 25