Skip to content

Instantly share code, notes, and snippets.

View nmhung's full-sized avatar
👨‍💻

Ken nmhung

👨‍💻
View GitHub Profile
@nmhung
nmhung / BottomNavigationBehavior.kt
Created September 15, 2018 14:38 — forked from ValCanBuild/BottomNavigationBehavior.kt
Full code of a BottomNavigationBehavior which hides itself on scroll and handles Snackbars and FAB. https://medium.com/@ValCanBuild/scroll-your-bottom-navigation-view-away-with-10-lines-of-code-346f1ed40e9e
// Apply to BottomNavigationView
class BottomNavigationBehavior<V : View>(context: Context, attrs: AttributeSet) :
CoordinatorLayout.Behavior<V>(context, attrs) {
override fun layoutDependsOn(parent: CoordinatorLayout?, child: V, dependency: View?): Boolean {
if (dependency is Snackbar.SnackbarLayout) {
updateSnackbar(child, dependency)
}
return super.layoutDependsOn(parent, child, dependency)
}