1

I have a layout like below :

<ScrollView ...>

    <LinearLayout...>

            <EditText
                ..../>
  </LinearLayout>

</ScrollView>

As soon the fragment loads we set the focus of the EditText so that it displays Keyboard.

We have also set the background :

mParent = inflater.inflate(R.layout.sample_layout, container, false); mParent.setBackgroundResource(R.drawable.sample_bg);

The issue is that when the keyboard is shown the background resizes or the keyboard pushes the background image up.

mEdTxt.requestFocus();
        InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(mEdTxt, InputMethodManager.SHOW_IMPLICIT);

mEdTxt.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
                }
            }
        });

We have tried :

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

I have seen many posts revelant to this but didnt help me.

EDIT : Question is not Duplicate

How ?

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

The above code will disable the scroller.

We need the keyboard to be shown also the scroller to be present so that the user can scroll the page when the keyboard is shown.

I hope its clear.

Goofy
  • 6,098
  • 17
  • 90
  • 156
  • possible duplicate of [Software keyboard resizes background image on Android](http://stackoverflow.com/questions/4287473/software-keyboard-resizes-background-image-on-android) – Lamorak Apr 17 '15 at 08:04
  • @Lamorak i have seen that post its not a duplicate of that, i have even mentioned that in my Question.Please remove your comment. And if you have any solution please let me know – Goofy Apr 17 '15 at 08:08
  • Well sometimes the accepted answer is not the best one for you, have a look on the others, `scrollview` is mentioned there couple of times. – Lamorak Apr 17 '15 at 08:18

1 Answers1

0

Sounds like you have in the Activity node in your Manifest:

android:windowSoftInputMode="adjustResize"

If you don't want it to resize, remove this or change it to something different.

http://developer.android.com/guide/topics/manifest/activity-element.html

markt
  • 903
  • 7
  • 21