Created
January 8, 2020 14:40
-
-
Save sajjadjaved01/2b98d613e65b76a9386c5feb5079235a to your computer and use it in GitHub Desktop.
Android Animation using AndroidX Transition API.
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
/* usage fabMessages.toggle(Slide(Gravity.Bottom)) : Slide() & Fade() */ | |
fun View.toggle(transition: Transition) { | |
transition.duration = 500 | |
transition.addTarget(this) | |
TransitionManager.beginDelayedTransition(this.parent as ViewGroup, transition) | |
visibility = if (!isVisible) View.VISIBLE else View.GONE | |
} | |
// Usage extend any of your view with toggle, like (Button, FabButton, etc). | |
// use views Id. | |
// There are Two types of Transhions. (Fade(), Slide()) | |
// Gravity is where do you want it to slide from. | |
fabMessages.toggle(Slide(Gravity.Bottom)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment