0

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.

dreamtale
  • 2,905
  • 1
  • 26
  • 38

1 Answers1

0

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

balaji koduri
  • 1,321
  • 9
  • 25
  • The animation can't start if put the code in `onCreate`, as well i just followed the the developer guide : http://developer.android.com/guide/topics/graphics/drawable-animation.html – dreamtale Dec 09 '13 at 04:24