This is an simple example how you can show and hide a custom layout view using slide animation effect.
We are going to use one button for toggling a ConstraintLayout as a custom view for the animation effect (you can use whatever container view you prefer).

The preferred programming language for this example is Kotlin.

First we declare boolean variable set to false:

Inside onCreate we call setOnClickListener to our toggle button:

And the toggle effect for the view showing and hiding with animation effect:

Transition object holds information about animations that will be run on its targets during a scene change.

TransitionManager class manages the set of transitions that fire when there is a change of Scene. And delaying the showing/hiding the view using sliding animation with duration of 600 milliseconds, and to gravity END on screen (right side of the screen)

At the end we toggle the boolean value of isSidePanelShown so we can show/hide the view.

The layout:

 

The result:

 

You can get the whole project on GitHub BuktopMKD/ShowAndHideAnimation

Spread the love

Leave a Reply

Your email address will not be published.