It is necessary to hide the keyboard when scrolling occurs either up or down. I do this: a piece of markup code

<ScrollView android:id="@+id/scrollViewcontent" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.handlingcitizen.handlingcitizen.MainActivity" tools:showIn="@layout/app_bar_main"> 

I write in activity:

 public void hideKeyborScroll() { mScrollView.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { onClickAway(); } }); } protected void onClickAway() { if (getCurrentFocus() != null) { InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); } } 

reaction zero scrolling.

Maybe this is important: in the manifest I registered android:windowSoftInputMode="stateHidden" this parameter is important for me , in the markup for edittext (10pcs) for all your-va

 android:focusable="true" android:focusableInTouchMode="true" android:clickable="true" 
  • Perhaps you need to hide the clave, not by the change of focus event, but by the scrolling event? setOnScrollListener - Yuriy SPb
  • @YuriSPb ie all the same, but only the handler to change? - upward
  • Yes, sort of. But you have to try - various problems can come out - YuriySPb

2 answers 2

 scrollView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { final Activity activity = YourActivity.this; final View view = activity.getWindow().getDecorView(); if (view != null) { final InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } return false; } }); 

    You can use this code on a specific EditText:

     YourEditText.clearFocus();