键盘在滚动时隐藏

时间:2020-10-28 13:27:57

标签: android android-edittext textinputlayout

在我的xml中,我在NestedRecyclerView中包含TextInputLayout edittext,当焦点位于第一个edittext上时,我将聚焦于第二个edittext上,然后隐藏并显示键盘,在滚动时也隐藏了键盘,但焦点仍然存在。 任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

在项目代码中实现OnTouchListener

MyRecycleView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

        return false;
    }
});

这可能会帮助您Implementation of RecyclerView that will dismiss keyboard