0
点赞
收藏
分享

微信扫一扫

AnimationDrawable 不能显示问题

f12b11374cba 2023-03-31 阅读 89


启动Frame Animation动画的代码rocketAnimation.start();不能在OnCreate()中,因为在OnCreate()中 AnimationDrawable还没有完全的与ImageView绑定


这个时候是不能显示的, 在onWindowFocusChanged中可以显示出动画


public void onWindowFocusChanged(boolean hasFocus) 
{
        super.onWindowFocusChanged(hasFocus);
        if(hasFocus)
        {
        rose.setBackgroundDrawable(getAnimationDrawable(0));
        aniDraw = (MyAnimationDrawable) rose.getBackground();
aniDraw.setVisible(true, true);
aniDraw.invalidateSelf();
aniDraw.stop();
aniDraw.start();
        }
}

举报

相关推荐

0 条评论