Fresco Image Library by Facebook

Fresco is a powerful image displaying library maintained by Facebook in Android applications.

Fresco takes care of image loading and image display from the Internet, local storage or local resources and displays a placeholder until the image is downloaded. It has two levels of cache in memory and in internal storage.

The reason of its talk is following features:

  • Streaming of progressive JPEGs
  • Display of animated GIFs and WebPs
  • Extensive customization of image loading and display

Lets go to the implementation part of Fresco.


Add the Fresco dependency in your app/build.gradle file:

compile 'com.facebook.fresco:fresco:1.0.0'

Make sure we have the Internet permission if you plan to fetch any images from the network:

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

Initialize Fresco in onCreate() method, before setContentView() method.

Fresco.initialize(this);

Include it in your layout:

 <com.facebook.drawee.view.SimpleDraweeView
     android:padding="20dp"
     android:layout_width="match_parent"
     android:layout_height="300dp"
     fresco:fadeDuration="3000"
     android:id="@+id/frescoImage"
     fresco:placeholderImage="@drawable/place_holder"
     fresco:failureImage="@drawable/failed_image"
     />

Finally, set the actual image URI:

Uri imageUri = Uri.parse("https://pawanthepro.files.wordpress.com/2016/12/msdhoni1.jpg");
frescoImage.setImageURI(imageUri);

Output:

fresco_output