I have tried some approach and since we have different screen size, I am not able to get a better way. Here is my code
private val scrollContainer
get() = View.findViewById<NestedScrollView>(R.id.scroll_container)
scrollContainer.setOnScrollChangeListener { _, _, newScrollY, _, oldScrollY ->
val length = 1.5
val deltaScrollY = newScrollY - oldScrollY
if (deltaScrollY > length) {
View.hide()
}
if (deltaScrollY < -length) {
View.show()
}
}