Last active
March 12, 2019 15:53
-
-
Save brainail/3681d73d25102f8a3949d1befe776bdc to your computer and use it in GitHub Desktop.
Show/hide com.google.android.material.bottomappbar.BottomAppBar programmatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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