
ImageVIEw globe = (ImageVIEw) findVIEwByID(R.ID.globe);AnimationDrawable animation = new AnimationDrawable();animation.setoneshot(true);Resources res = this.getResources();while (from <= to) { String name = "globe_" + String.format("%03d",from); int globeID = res.getIDentifIEr(name,"drawable",this.getPackagename()); animation.addFrame(res.getDrawable(globeID),200); from++;}globe.setBackgroundDrawable(animation);globe.post(new Runnable(){ @OverrIDe public voID run() { animation.start(); }});解决方法 所以Animation.addFrame(Drawable frame,int duration)需要一个可以从Bitmap创建的drawable. 如果您的图像列表是动态加载的:
@R_419_6818@<Bitmap> images;int duration = 200; for(Bitmap image: images){ BitmapDrawable frame = new BitmapDrawable(image); animation.addFrame(frame,duration);} 试试这个,一定要工作.
总结以上是内存溢出为你收集整理的android – AnimationDrawable以编程方式没有动画列表xml全部内容,希望文章能够帮你解决android – AnimationDrawable以编程方式没有动画列表xml所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)