Fresco使用
来源:互联网 发布:淘宝怎么换支付宝绑定 编辑:程序博客网 时间:2024/05/17 23:03
Fresco是最全,最好,但是体积也比较大的图片处理的开源框架,能够从网络,内存,缓存中加载图片,节省了流量和CPU资源,实现三级缓存,底层使用的C,所以对图片的内存管理非常高效.
使用Fresco的步骤:
1. 进行关联,在build.gradle里dependencies添加 compile 'com.facebook.fresco:fresco:0.12.0' 即可
提示:Fresco可以实现非常多的功能,所以如果有其他需求,还要在build.gradle里dependencies添加对应关联
// 在 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'
// 仅支持 WebP 静态图,需要添加
compile 'com.facebook.fresco:webpsupport:0.12.0'
2. 初始化Fresco类,在自定义的Application中,添加: Fresco.initialize(this);
提示:在清单文件里配置你的Application.
3. 在清单文件里配置网络权限.
4.在XML布局文件中,加入命名控件(在你使用Fresco控件的布局xml文件里)<uses-permission android:name="android.permission.INTERNET"/>
<!-- 其他元素--><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fresco="http://schemas.android.com/apk/res-auto" android:layout_height="match_parent" android:layout_width="match_parent">5.加入SimpleDraweeView:
<com.facebook.drawee.view.SimpleDraweeView android:id="@+id/my_image_view" android:layout_width="130dp" android:layout_height="130dp" fresco:placeholderImage="@drawable/my_drawable" />
6. 代码中加载图片:
Uri uri = Uri.parse("https://raw.githubusercontent.com/facebook/fresco/gh-pages/static/logo.png"); SimpleDraweeView draweeView = (SimpleDraweeView) findViewById(R.id.my_image_view); draweeView.setImageURI(uri);
- Fresco使用
- Fresco使用
- Fresco 使用
- Fresco使用
- Fresco使用
- Fresco初探-使用Fresco显示图片
- Fresco的使用
- Fresco使用总结
- Fresco 使用笔记
- Fresco使用注意点
- fresco使用文档地址
- fresco使用文档地址
- Fresco 基础使用
- fresco使用笔记
- Eclipse使用Fresco
- 使用Fresco加载图片
- Fresco的简单使用
- Fresco使用介绍
- JavaScript 精粹 基础 进阶(7)函数和作用域(闭包、作用域)
- redis如何关闭持久化
- 【JZOJ4928】【NOIP2017提高组模拟12.18】A
- COM编程精彩实例--COM对象
- 如何把IP号段转换成CIDR格式
- Fresco使用
- 利用POI将word转换成html实现在线阅读
- 程序员面试金典: 9.1数组与字符串 6将图像旋转90度
- 13.适配器模式
- JavaScript 精粹 基础 进阶(8)OOP面向对象编程(上)
- Internet 控制消息协议
- Web Api 托管
- c bool 和c++bool 的区别
- 很好的找工作内容