Fresco 加载图片

一.导入依赖

  //    fresco依赖
    compile 'com.facebook.fresco:fresco:0.11.0'

xml
圆形图:fresco:roundAsCircle=”true”

 <com.facebook.drawee.view.SimpleDraweeView
        fresco:roundAsCircle="true"
        android:id="@+id/attention_item_fresco"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:src="@mipmap/ic_launcher" />

二.自定义一个MyApp类 然后继承 Application

public class MyApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
       Fresco.initialize(this);
    }
}

三.在清单文件中 添加 android:name=”.view.MyApp”

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:name=".view.MyApp">

四.适配器
注意:setImageURI

  String image_url = list.get(position).getImages().split("\\|")[0];
        holder.getXrecycler_img().setImageURI(image_url);

猜你喜欢

转载自blog.csdn.net/shitou0/article/details/79834214