
Picasso Image Library in Android
Picasso Library is an open source android library which is developed and maintained by Square. In this Library used to Download image from url to local storage. Picasso is a powerful image downloading and caching library.
Picasso Library Features
It is Easy to use and reduces the code.
It is Automatic memory and cache management.
Allows Image Transformation.
It is Resizing and Scaling,Center Cropping etc.
Example of Fresco Library in Android How to work Fresco Library in Android
Implement Dependency in app level build.gradle file.
1 |
Implementation 'com.squareup.picasso:picasso:2.5.2' |
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"> <ImageView android:id="@+id/image_view_picasso" 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 |
package com.example.bhaumik; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ImageView; import com.squareup.picasso.Picasso; public class MainActivity extends AppCompatActivity { String url = "https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/flip.jpg"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ImageView imageView = (ImageView) findViewById(R.id.image_view_picasso); Picasso.with(MainActivity.this).load(url).into(imageView); } } |
In this Example used to Picasso Image Download Library. in this library implements and then Picasso define code Line and pass the URL to download image from internet and then display imageView to set ImageView in Picasso.