Android Flicker when using Animation and onAnimationEnd Listener

后端 未结 2 1089
青春惊慌失措
青春惊慌失措 2021-01-26 18:11

I have 3 ImageButtons which are animated when Filling to left, like this:

public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY         


        
相关标签:
2条回答
  • 2021-01-26 18:21

    Ana, I think you have already read my answers here

    Android TranslateAnimation resets after animation

    android animation is not finished in onAnimationEnd

    I had also replied to your comment, basically in stead of doing the functionality inside the mAnimation.setAnimationListener method, you need to create custom ImageButtons and put the functionality there

    public Class myImageButton extends ImageButton {
    @Override
        protected void onAnimationEnd() {
            super.onAnimationEnd();
            //Functionality here
        }
    
    0 讨论(0)
  • 2021-01-26 18:25

    I searched for all stackoverflow posts for animation issue (flicker and sluggish). I didnt find any perfect answer. But I have found the solution for the same, which is as below,

    onStart of Animation use,

    view_you_want_to_animate.setDrawingCacheEnabled(true);
    

    onEnd of Animation use,

    view_you_want_to_animate.setDrawingCacheEnabled(false);
    

    Now my view does not have flicker or sluggish behavior when my view is animating. I works well for me.

    0 讨论(0)
提交回复
热议问题