帧动画代码实现示例
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();
最后,关注【码上加油站】微信公众号后,有疑惑有问题想加油的小伙伴可以码上加入社群,让我们一起码上加油吧!!!