class BottomNavigationFABBehavior(context: Context?, attrs: AttributeSet?) : CoordinatorLayout.Behavior(context, attrs) { override fun layoutDependsOn(parent: CoordinatorLayout, child: View, dependency: View): Boolean { return dependency is Snackbar.SnackbarLayout } override fun onDependentViewRemoved(parent: CoordinatorLayout, child: View, dependency: View) { child.translationY = 0f } override fun onDependentViewChanged(parent: CoordinatorLayout, child: View, dependency: View): Boolean { return updateButton(child, dependency) } private fun updateButton(child: View, dependency: View): Boolean { if (dependency is Snackbar.SnackbarLayout) { val oldTranslation = child.translationY val height = dependency.height.toFloat() val newTranslation = dependency.translationY - height child.translationY = newTranslation return oldTranslation != newTranslation } return false } }