Fresco load image

1. Import dependencies

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

xml
circle diagram: 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" />

2. Customize a MyApp class and inherit Application

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

3. Add android:name=”.view.MyApp” to the manifest file

<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">

4. Adapter
Note: setImageURI

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325686813&siteId=291194637