florent37 / ViewAnimator

A fluent Android animation library
Apache License 2.0
2.71k stars 423 forks source link

Starting animation from visibility GONE #34

Open royhenengel opened 7 years ago

royhenengel commented 7 years ago

Hi, I'm trying to animate a view when it's starting visibility state is View.GONE. When setting view visibility on animation start to View.VISIBLE, the animation results in a very short blink because of the visibility change. Can you recommend me maybe a better way to animate the view with a starting state of View.GONE?

Code:

ViewAnimator
.animate(view)
.onStart(new AnimationListener.Start() {
        @Override
        public void onStart()
            {
                view.setVisibility(View.VISIBLE);
            }
        })
.duration(400)
.zoomIn()
.start();

Thank you

ghost commented 7 years ago

You could use the alpha method...

In your case

ViewAnimator .animate(view) .alpha(0f, 1f) // fades in from 0f to 1f .duration(400) .zoomIn() .start();

before you fade in/out, you must've set the initial alpha level to 0f at the beginning of your code:

view.setAlpha(0f)

florent37 commented 6 years ago

yes ;)