Skip to content

Instantly share code, notes, and snippets.

View bitsydarel's full-sized avatar

Darel Bitsy bitsydarel

View GitHub Profile
@bitsydarel
bitsydarel / BottomNavigationViewBehavior.kt
Created February 15, 2018 18:30
Layout behavior for Bottom Navigation View to hide and show on scroll. Root ViewGroup should be CoordinatorLayout.
class BottomNavigationViewBehaviour(context: Context, attrs: AttributeSet) : CoordinatorLayout.Behavior<BottomNavigationView>(context, attrs) {
private var height: Int = 0
override fun onLayoutChild(parent: CoordinatorLayout?, child: BottomNavigationView?, layoutDirection: Int): Boolean {
height = child!!.height
return super.onLayoutChild(parent, child, layoutDirection)
}
override fun onStartNestedScroll(coordinatorLayout: CoordinatorLayout, child: BottomNavigationView, directTargetChild: View, target: View, axes: Int, type: Int): Boolean {