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