Pavlo Viazovskyy Pavlo Viazovskyy - 1 month ago 18
Android Question

How to avoid blink of View when using animation?

I use translate and rotate animations to position

View
inside
FrameLayout
in
onCreate
event. I want animations to perform instantly so I set duration for both of them to 0. But when application starts there is a short blink of my
View
in top left corner of screen and then it becomes positioned according to animation parameters. How can I avoid this blink?

Answer

I spent whole day with that problem. fillAfter and fillBefore has nothing to do with that. Try this before animation start:

view.setVisibility(View.GONE); // view is our View we trying to animate

Then set animation listener for your animation:

    animation.setAnimationListener(new AnimationListener(){
        public void onAnimationEnd(Animation animation) {
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationStart(Animation animation) {
            v.setVisibility(View.VISIBLE);
        }