1

How can I acheive such behavior for bottom bar? It works like scroll aware behavior for floating action button but when the recyckerview scrolls to the bottom, then it pulls that panel up (like the last element in the recyclerview is that panel). I don't think that the developer duplicated those views. Maybe it is possible to extend behavior somehow?

Here is the code for scroll aware behavior:

class ScrollAwareBehavior : CoordinatorLayout.Behavior<View> {
    constructor() : super()
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)

    override fun onStartNestedScroll(coordinatorLayout: CoordinatorLayout?, child: View?, directTargetChild: View?, target: View?, nestedScrollAxes: Int): Boolean {
        return nestedScrollAxes==ViewCompat.SCROLL_AXIS_VERTICAL
    }

    override fun onNestedScroll(coordinatorLayout: CoordinatorLayout?, child: View?, target: View?, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int) {
        super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed)
        if (dyConsumed > 0) {
            val layoutParams = (child?.layoutParams as? CoordinatorLayout.LayoutParams?)?:return
            val fab_bottomMargin = layoutParams.bottomMargin
            child?.animate()?.translationY(child.height.toFloat() + fab_bottomMargin)?.setInterpolator(AccelerateDecelerateInterpolator())?.start()
        } else if (dyConsumed < 0) {
            child?.animate()?.translationY(0f)?.setInterpolator(AccelerateDecelerateInterpolator())?.start()
        }
    }
}
Mykhailo Yuzheka
  • 713
  • 1
  • 7
  • 24
  • [This] (https://stackoverflow.com/questions/34715732/how-to-scroll-up-down-of-bottom-bar-on-scrolling-of-recyclerview) may help – Shubham Goel Jun 09 '17 at 12:25
  • I have already achieved that. I only can't figure out how to show that panel without overlapping the list when it is scrolled to the very bottom. – Mykhailo Yuzheka Jun 09 '17 at 12:33

1 Answers1

0

One way of doing that it's to listen the scroll event on the RecyclerView and check the last visible item and check if it's the last one.
For that, there is findLastCompletelyVisibleItemPosition() in LinearLayoutManager and getItemCount() in Adapter.

Kevin Robatel
  • 8,025
  • 3
  • 44
  • 57
  • But how to slide out that bar together with recyclerview scrolling? – Mykhailo Yuzheka Jun 10 '17 at 15:01
  • Maybe you can use `findLastVisibleItemPosition()`, check if it's the last one, take its `top` value, and apply it to your "bar". (maybe you have to add a padding to the bottom of your recyclerview and add the height of the padding to the top). Do you get it? – Kevin Robatel Jun 11 '17 at 11:37