I need to make two buttons that pop up below that appear when scrolling.
I will show on the example of the application Aliexpress. When scrolling, the "Filter" and "Characteristics" buttons smoothly go out with us:

When scrolling, the "Filter" and "Characteristics" buttons smoothly exit from us.

And when scrolling up, these buttons disappear:

enter image description here

When I used LinearLayout with ScrollView , I simply connected the OnScrollChangeListener handler and, depending on the scroll direction, I started the necessary animation for the buttons, but when I connect this handler to RecyclerView , the handler reacts to the scroll, but oldScrollY and scrollY are 0.

    1 answer 1

    For these purposes it is necessary to use RecyclerView.OnScrollListener . In its onScroll method onScroll is a dy parameter that is responsible for scrolling along the y axis. This parameter transmits the number of pixels scrolled in 1 motion. The value can be either positive (scrolling down) or negative (scrolling up). An example of use can be found here.

    As for the panel itself - there are several options for implementation:

    • RelativeLayout as the parent ViewGroup for this panel + android:layout_alignParentBottom="true" in the xml properties of the panel
    • FrameLayout as the parent ViewGroup for this panel + android:layout_gravity="bottom" in the xml properties of the panel

    For animation, you can use the excellent SlideUp library, which has many buns under the hood to create your own slider.

    There is also one more panel implementation:

    • CoordinatorView as the parent ViewGroup for this panel + BottomSheetBehavior

    Google - documentation and sample use