First, add Fresco to your build.gradle as shown in the Remarks section:
If you need additional features, like animated GIF or WebP support, you have to add the corresponding Fresco artifacts as well.
Fresco needs to be initialized. You should only do this 1 time, so placing the initialization in your Application is a good idea. An example for this would be:
If you want to load remote images from a server, your app needs the internt permission. Simply add it to your AndroidManifest.xml:
Then, add a SimpleDraweeView to your XML layout.
Fresco does not support wrap_content for image dimensions since you might have multiple images with different dimensions (placeholder image, error image, actual image, ...).
So you can either add a SimpleDraweeView with fixed dimensions (or match_parent):
Or supply an aspect ratio for your image:
Finally, you can set your image URI in Java:
That's it! You should see your placeholder drawable until the network image has been fetched.
JPEG Streaming with Fresco using DraweeController
This example assumes that you have already added Fresco to your app (see this example):
Using OkHttp 3 with Fresco
First, in addition to the normal Fresco Gradle dependency, you have to add the OkHttp 3 dependency to your build.gradle:
When you initialize Fresco (usually in your custom Application implementation), you can now specify your OkHttp client:
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0