
Fresco Image Library in Android
Fresco Library is a Download image from server. In this Library Facebook app, images loading is performed by Fresco. This is a library written by Facebook developers. It is a powerful system for displaying images in Android applications.
Fresco Library is a caching images in memory or internal storage, It can not have to submit the requests to load images multiple times.
Fresco Library is created by Facebook developers that can be used to display image from internet or local storage. Many popular android apps like facebook, twitter, wikipedia etc uses this library.
It is better than other Image Library of Picasso and Glide. It is manage memory efficiently in app works faster and causes less crashes.
Example Of Fresco Image Library in Android
Implement Dependency in app level build.gradle file.
1 |
implementation 'com.facebook.fresco:fresco:1.13.0' |
You Must Declared Internet Permission in AndroidManifest.xml File.
1 |
<uses-permission android:name="android.permission.INTERNET" /> |
Create activity_main.xml File Follow this code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.bhaumik.MainActivity"> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/simple_draweeView" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout> |
Create MainActivity.java File Follow this Code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
package com.example.bhaumik; import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import com.facebook.drawee.backends.pipeline.Fresco; import com.facebook.drawee.view.SimpleDraweeView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fresco.initialize(this); setContentView(R.layout.activity_main); SimpleDraweeView simpleDraweeView = (SimpleDraweeView) findViewById(R.id.simple_draweeView); Uri uri = Uri.parse("https://tinypng.com/images/social/developer-api.jpg"); simpleDraweeView.setImageURI(uri); } } |
In this Example of Implement Fresco Library Dependency and Initialize Fresco in the MainActvity.java. then create SimpleDraweeView is a Fresco Library Provider. in this view define image url then put the url and download image File from internet and store local storage and display Image.