帧动画代码实现示例

    ImageView image = (ImageView) findViewById(R.id.frame_image);
        final AnimationDrawable anim = new AnimationDrawable();
        for (int i = 1; i <= 14; i++) {
            int id = getResources().getIdentifier("list_icon_gif_playing" + i, "drawable", getPackageName());//获取本地drawable资源文件
            Drawable drawable = getResources().getDrawable(id);
            anim.addFrame(drawable, 60);
        }

        anim.setOneShot(false);
        image.setBackgroundDrawable(anim);

        anim.start();

 

posted on 2018-12-29 11:36  LoaderMan  阅读(503)  评论(0编辑  收藏  举报

导航