androidandroid-edittextandroid-viewpagerandroid-keypadwindow-soft-input-mode

Soft keypad popsup and hides slowly in fragment and makes typing sluggish


I am using [SlidingMenu][1] in my app. I use Viewpager to show three fragments in tabs in a fragment. Three fragments have EditTexts inside LinearLayouts which are in ScrollView. So My XML XMl is like this:

RelativeLayout>ScrollView>LinearLayout>EditText .

After focus is changed to each EditText, typing starts very slowly(takes 1-2 secs to respond). I thought it's because of Soft keypad that tries to resize or pan everytime. So I tried all possible values for windowSoftInputMode. Nothing works. I used same XML in an Activity, where typing is very smooth. Also after typing is done(when user clicks IME done button), keypad hiding is very very slow(takes 3 secs). What could be the problem? and any workaround to avoid?

By the way, I don't have any TextWatchers set for EditTexts.

Edit:

When I remove EditTexts from other two fragments, it's smooth. But only when all the three fragments have EditTexts, it's sluggish.


Solution

  • I avoided this by adding android:windowSoftInputMode="adjustNothing" which does no resizing and no scrolling. And added Focus listeners to edit texts which are at the bottom part of the screen so that they get visible to the users while typing.

    editText.setOnFocusChangeListener(new OnFocusChangeListener() {
    
                @Override
                public void onFocusChange(View v, boolean hasFocus) {
                    if (hasFocus) {
                        scroll.scrollTo(rootView.getWidth(), rootView.getHeight()); //rootView is my parentView of the fragment
                    }
    
                }
            });
    

    However, if anyone knows an elegant solution, please post it.