Skip to content

Instantly share code, notes, and snippets.

@brainail
Last active March 12, 2019 15:53
Show Gist options
  • Save brainail/3681d73d25102f8a3949d1befe776bdc to your computer and use it in GitHub Desktop.
Save brainail/3681d73d25102f8a3949d1befe776bdc to your computer and use it in GitHub Desktop.
Show/hide com.google.android.material.bottomappbar.BottomAppBar programmatically
class AppCompatBottomAppBar : BottomAppBar {
private val compatBehavior by lazyFast { CompatBehavior() }
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) // respect internal style
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
override fun getBehavior(): CoordinatorLayout.Behavior<BottomAppBar> {
return compatBehavior
}
private inner class CompatBehavior : BottomAppBar.Behavior() {
fun show() {
slideUp(this@AppCompatBottomAppBar)
}
fun hide() {
slideDown(this@AppCompatBottomAppBar)
}
}
fun show() {
compatBehavior.show()
}
fun hide() {
compatBehavior.hide()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment