Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with hide_bottom_view_on_scroll_behavior #5

Open
shahrukhmlk opened this issue Aug 29, 2018 · 1 comment
Open

Not working with hide_bottom_view_on_scroll_behavior #5

shahrukhmlk opened this issue Aug 29, 2018 · 1 comment

Comments

@shahrukhmlk
Copy link

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
Copy link

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)
            }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants