Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 750
Pavlo Viazovskyy Avatar asked Oct 09 '12 11:10

Pavlo Viazovskyy


1 Answers

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);
        }
like image 199
Oleh Luchkiv Avatar answered Oct 12 '22 06:10

Oleh Luchkiv