DrawableAnimation cause the layout flicking

91 views Asked by At

I have an view which has an DrawableAnimation background in the layout, I get the animation drawable and start animation or stop animation like below code

private void init() {
    xxx.setBackgroundResource(R.drawable.avatar_wave_profile);
    mAnimationDrawable = (AnimationDrawable)mAvatarWave.getBackground();
} 

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    if (hasFocus) {
        mAnimationDrawable.start();
    } else {
        mAnimationDrawable.stop();
    }
}

But when i touch the layout or the layout is moving(in an sliding menu), it will flicker. so how to avoid this problem, any advice will be appreciated.

1

There are 1 answers

1
balaji koduri On

remove that animation controlling functionality in onWindowFocusChange() and place in init() method, Becose onWindowFocusChange() calls when window focus is changed this method will call.

plz check this reference.Activity