将gif保存到android库
发布时间:2020-12-14 23:25:31 所属栏目:资源 来源:网络整理
导读:使用 https://github.com/koush/ion图像加载程序将gif文件显示到ImageView中 我通过此代码将jpg图像保存到图库中 MediaStore.Images.Media.insertImage( getActivity().getContentResolver(),bitmap,"XXX","Image1"); 但这种方式不适用于gif文件. 你知道我怎
使用
https://github.com/koush/ion图像加载程序将gif文件显示到ImageView中
我通过此代码将jpg图像保存到图库中 MediaStore.Images.Media.insertImage( getActivity().getContentResolver(),bitmap,"XXX","Image1"); 但这种方式不适用于gif文件. 你知道我怎么能做到这一点? 解决方法
你可以使用这段代码保存gif
File file = new File(getBaseContext().getExternalCacheDir(),"gif_name"+ ".gif"); try { FileOutputStream fos = new FileOutputStream(file); fos.write(gif.getData());//gif is gif image object fos.flush(); fos.close(); } catch (IOException ioe) { ioe.printStackTrace(); } 此代码将gif保存在外部SD卡的缓存目录中,但在Gallery中不可见. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |