关于Fresco的
来源:互联网 发布:java file.getlength 编辑:程序博客网 时间:2024/06/07 08:28
其实关于fresco的使用还是比较简单的。不管要不要用,gradle中把这些加上去就好了。
compile 'com.facebook.fresco:fresco:0.12.0'// 在 API < 14 上的机器支持 WebP 时,需要添加compile 'com.facebook.fresco:animated-base-support:0.12.0'// 支持 GIF 动图,需要添加compile 'com.facebook.fresco:animated-gif:0.12.0'// 支持 WebP (静态图+动图),需要添加compile 'com.facebook.fresco:animated-webp:0.12.0'compile 'com.facebook.fresco:webpsupport:0.12.0'然后在xml中,哪里需要使用图片加载的就把这个fresco给放上去。
<com.facebook.drawee.view.SimpleDraweeView android:id="@+id/my_test_view" android:layout_width="100dp" android:layout_height="100dp" />
唯一提一下的是,facebook的fresco的时候碰到一个坑。错误日志如下:
java.lang.RuntimeException:
Unable to start activity ComponentInfo{com.---.---.---/com.---.---.---.MainActivity}:
android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.facebook.drawee.view.SimpleDraweeView
关于这个错误,我觉得可能是fresco文档写的不够好,虽然文档中说明了在onCreate的时候初始化fresco。但是初始化必须在setContentView之前。
如果出现这个错误,换个顺序就能解决。但是如果没注意到它,估计也让你觉得很懵逼。别的没什么好强调的,fresco还是挺好用的。
super.onCreate(savedInstanceState);Fresco.initialize(this);setContentView(R.layout.activity_main);
再补充一点:
在使用fresco时,在xml中调用fresco的方法时,如果出现
Error:(9) Error parsing XML: unbound prefix
这个和我们调用android:其实时一样的。安卓xml文件头部我们会声明
xmlns:android="http://schemas.android.com/apk/res/android"
同样fresco也要声明,在xml的上增加下面这行代码就搞定了
xmlns:fresco="http://schemas.android.com/apk/res-auto"
阅读全文
0 0
- 关于Fresco的介绍
- 关于Fresco的
- 关于fresco的属性介绍
- 关于Studio导入Fresco的问题
- 关于Fresco的三级缓存机制
- 关于Fresco的缓存清理的那些事
- 关于fresco的使用之--CacheKey获取本地缓存
- Fresco的使用
- Fresco的简单实用教程
- Fresco的简单使用
- Fresco的入门篇
- Fresco的相关
- Fresco的使用
- Fresco.initializeDrawee()的过程
- Fresco框架的介绍
- Fresco的初步使用
- Fresco的缓存机制
- fresco的详细了解
- CentOS 7 中firewall-cmd命令
- linux安装elasticsearch5.5
- document.forms[].submit()
- MATLAB匿名函数的应用6
- Gson 解析教程
- 关于Fresco的
- SGISTL源码探究-stl_numeric.h中的数值算法
- C/C++中 变量的存储位置
- Nginx 启动步骤
- 【解决】postman调试oAuth2.0第三方接口
- HttpServletRequest介绍
- 微信退款结果通知报文AES解密
- 侧拉菜单传值
- springmvc的ModelAttribute注解