Not working with hide_bottom_view_on_scroll_behavior
shahrukhmlk opened this issue · 1 comments
shahrukhmlk commented
It works fine with the appbar, all the scroll bahaviours in the parent coordinator layout work as expected for app bar. But if there is a Bottom Navigation View with @string/hide_bottom_view_on_scroll_behaviour, it does not hide when child coordinator layout views scroll.
dsuresh-ap commented
I got this to work by copying the logic in HideBottomViewOnScrollBehavior
into my own behavior class and then overriding onNestedPreScroll
.
override fun onNestedPreScroll(
coordinatorLayout: CoordinatorLayout,
child: BottomNavigationView,
target: View,
dx: Int,
dy: Int,
consumed: IntArray,
type: Int
) {
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type)
onNestedScroll(coordinatorLayout, child, target, dx, dy, consumed[0], consumed[1], type)
}
override fun onNestedScroll(
coordinatorLayout: CoordinatorLayout,
bottomNavigationView: BottomNavigationView,
target: View,
dxConsumed: Int,
dyConsumed: Int,
dxUnconsumed: Int,
dyUnconsumed: Int
) {
if (currentState != STATE_SCROLLED_DOWN && dyConsumed > 0) {
slideDown(bottomNavigationView)
} else if (currentState != STATE_SCROLLED_UP && dyConsumed < 0) {
slideUp(bottomNavigationView)
}
}