I want to hide keyboard if user starts scrolling in RecyclerView
.
dy
is scrolled distance if I understood that correctly, and if it passes certain value, I can hide keyboard.
But I found out if you press and hold the finger on screen and scroll slowly, it will not change dy
value (its still 1
) that means my method is not working.
Anyone know other alternative how to handle this specific usecase?
Code:
list.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
if (dy.absoluteValue > KEYBOARD_HIDE_DIST) editText.clearFocus()
}
})