I have a view that is invisible
by default(Just for the first time).
Now I need to switch the visibility to VISIBLE
with this animation
:
if (myView.getVisibility() == View.INVISIBLE) {
myView.setVisibility(View.VISIBLE);
myView.animate().translationY(0);
}
(Like the SnackBar default animation)
But this isn't working. It will turn visible with default animation
Is there any simple way that I could achieve this?
Note
I'm animating my view to dismiss, like this:
myView.animate().translationY(myView.getHeight());
You can do this using
XML
animation.Create a
slide-up
animationXML
usingset
andalpha
and put thisXML
into your resourceanim
folder.slide_up.xml
USE:
Use
AnimationUtils.loadAnimation()
to load animation fromXML
and set and start animation using.startAnimation()
method.Here is an example:
Hope this will help~
Based on this answer:
with this methods, I can set the
visibility
of my view toVISIBLE
with aslideUp
animation(Likesnackbar
animation):Then I can use it like this:
Add animations using ConstraintLayout
Just add below code above the views whose visibility is updated:
For more see this post https://robinhood.engineering/beautiful-animations-using-android-constraintlayout-eee5b72ecae3