Fresco图片框架初始化介绍

来源:互联网 发布:淘宝联盟返利靠谱吗 编辑:程序博客网 时间:2024/06/01 16:33

之前项目里面一直使用ImageLoder,现在想换个 图片加载框架,看到大家提到的最多的Fresco框架很好用, Fresco是facebook推出的一款强大的图片加载的框架。

1:由于我的开发工具是studio,所以需要在gradle中配置一下

compile 'com.facebook.fresco:fresco:0.10.0+'

2:同时需要在Application中初始化一下

Fresco.initialize(context); 

3:加载网络图片时还需要有网络权限。

<uses-permission android:name="android.permission.INTERNET"/>  

4:布局文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    xmlns:fresco="http://schemas.android.com/apk/res-auto"  
    android:layout_width="match_parent"  
    android:layout_height="match_parent">  
  
    <com.facebook.drawee.view.SimpleDraweeView  
        android:id="@+id/image_view"  
        android:layout_width="300dp"  
        android:layout_height="300dp"  
        fresco:placeholderImage="@mipmap/ic_launcher"/>  
  
</LinearLayout> 

5:开始使用

SimpleDraweeView draweeView = (SimpleDraweeView) findViewById(R.id.image_view);
Uri uri = Uri.parse("图片的网络地址");  
imageView.setImageURI(uri); 


0 0
原创粉丝点击