I have a LinearLayout
that I want to show or hide with an Animation
that pushes the layout upwards or downwards whenever I change its visibility.
I've seen a few samples out there but none of them suit my needs.
I have created two xml files for the animations but I do not know how to start them when I change the visibility of a LinearLayout
.
I was having troubles understanding an applying the accepted answer. I needed a little more context. Now that I have figured it out, here is a full example:
MainActivity.java
activity_mail.xml
Notes
INVISIBLE
.INVISIBLE
. If you are not animating completely off screen, though, then you can add an alpha animation and set the visibility with anAnimatorListenerAdapter
.you can slide up and down any view or layout by using bellow code in android app
Now visibility change animations should be done via
Transition API
which available in support (androidx) package. Just call TransitionManager.beginDelayedTransition method with Slide transition then change visibility of the view.activity_main.xml
Check this answer with another default and custom transition examples.
Here is my solution. Just get a reference to your view and call this method:
No need to do anything else =)
You can used the simple three lines of code to show the animation...