[置顶] Fresco图片加载框架学习和那些坑
2017-01-25 21:45
295 查看
1.
compile 'com.facebook.fresco:fresco:0.12.0' // 支持 GIF 动图,需要添加 compile 'com.facebook.fresco:animated-gif:0.12.0'
可选项:
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' }
开始使用 Fresco
如果你仅仅是想简单下载一张网络图片,在下载完成之前,显示一张占位图,那么简单使用SimpleDraweeView 即可。SimpleDraweeView 什么鬼一个自定义的Imageviewpublic class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Fresco.initialize(this);
}
}
布局中使用(注意了:
强制性的宽高
你必须声明android:layout_width和
android:layout_height。如果没有在XML中声明这两个属性,将无法正确加载图像。
wrap_content
Drawees 不支持wrap_content属性。所下载的图像可能和占位图尺寸不一致,如果设置出错图或者重试图的话,这些图的尺寸也可能和所下载的图尺寸不一致。如果大小不一致,假设使用的是
wrap_content,图像下载完之后,View将会重新layout,改变大小和位置。这将会导致界面跳跃。,)
<com.facebook.drawee.view.SimpleDraweeView android:id="@+id/my_image_view" android:layout_width="200dp" android:layout_height="wrap_content" fresco:roundedCornerRadius="5dp" fresco:roundBottomLeft="false" fresco:roundBottomRight="false" fresco:roundWithOverlayColor="#0000ff" fresco:roundingBorderWidth="1dp" fresco:roundingBorderColor="#ff0000" fresco:viewAspectRatio="1.33" fresco:placeholderImage="@mipmap/ic_launcher" />act 中使用
final Uri uri = Uri.parse("http://n.sinaimg.cn/eladies/20170103/vIpy-fxzencv3828038.jpg"); draweeView= (SimpleDraweeView) findViewById(R.id.my_image_view); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { draweeView.setImageURI(uri); } });
更多酷炫功能参考一下doc 官网(定制网络底层,加载自定义view ,和Vollery结合,和Okhttp ,多图复用)
https://www.fresco-cn.org/docs/using-drawees-xml.html
相关文章推荐
- FaceBook开源图片加载框架Fresco的学习使用(一), Fresco下载与简单使用
- Android-Universal-Image-Loader异步加载图片框架学习研究
- 一、Android 图片加载框架 Fresco 入门
- 【Android】Fresco图片加载框架(二)————Producer
- 初识Facebook的强大Android图片加载的框架:Fresco
- Fresco-Facebook的图片加载框架的使用
- Android-Universal-Image-Loader异步加载图片框架学习研究
- 图片加载框架Fresco使用总结
- 【Android】Fresco图片加载框架(一)————源码简要分析
- Volley框架学习(二)使用Volley实现异步加载图片
- 【Fresco】真正实现三级缓存的第三方图片加载框架
- 安卓图片加载框架的学习
- 安卓网络通信框架Volley学习(二)基于Volley高效加载网络图片
- Fresco图片加载框架之自总结Demo分享
- Android强大的图片加载框架Fresco简单用法
- IOS学习之路二十三(EGOImageLoading异步加载图片开源框架使用)
- Android 实现图片缓存异步加载框架学习笔记
- Android图片加载框架比较----Glide,Picasso,Fresco
- Android图片加载框架:ImageLoader,Volley,Picasso,Glide,Fresco
- 开源图片加载框架——Universal-Image-Loader学习