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()
}
})
Use this function computeVerticalScrollOffset() on recyclerView it will give the offset of scroll position
Not started with kotlin yet, Hence I have added java code. Hope you got the thing. Let me know if it works for you