0

I've been looking around all over on how to deal with the android keyboard messing up my UI elements and so far I have android:windowSoftInputMode="adjustNothing" added to my manifest. This solves half of the problem where on the initial showing of the keyboard, my elements remain the same and unaltered, but when the keyboard is dismissed the adjustNothing setting does not take effect and the UI is altered.

I am using this block of code to get rid of the keyboard when somewhere other than the textfield is tapped:

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        View v = getCurrentFocus();
        if ( v instanceof EditText) {
            Rect outRect = new Rect();
            v.getGlobalVisibleRect(outRect);
            if (!outRect.contains((int)event.getRawX(), (int)event.getRawY())) 
    {
                v.clearFocus();
                InputMethodManager imm = (InputMethodManager) 
                getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
            }
        }
    }
    return super.dispatchTouchEvent( event );
}

Any help on this issues would be much appreciated. Thank you in advance!

devcodeguy
  • 11
  • 2

0 Answers0