How to load image from url android Example


Hi, Developer in this Android tutorial I am Sharing How to load image from URL android Example. here you can read an easy way to load an image on imageView From URL in android API Bitmap Image om ImageView with Picasso Library. in this article solve your android development like show image in Profile Activity, Show Image in Android ListView,  Display Image from URL in CircularImageView

  1. Add an CircularImageView in the XML layout.
  2. Get the instance of  ImageView in Activity class.
  3. Add Picasso library in your project Gradle module
  4. Display or show image on CircularImageView


Step 1:- Add a CirculerImageView Layout in your XML.



        app:civ_border_width="2dp" />


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


compile 'de.hdodenhof:circleimageview:2.1.0'
compile ''
compile ''
compile 'com.squareup.picasso:picasso:2.5.2'
compile ''

Step 2: Main Activity java class Add These code.

in java class get the UI instance and find id and implement this. and load a Url From JSON API and Show Display Image on CircularImageView from Image API Url.

public class Profile extends AppCompatActivity {

    ImageView ProfileImage;
    protected void onCreate(Bundle savedInstanceState) {


Picasso is a library in android to load an image from URL 

Android Picasso features :

  • Resizing and Scaling
  • Center Cropping
  • Rotation and Transformation
  • Setting the Placeholder and Error images
  • Fading
  • Disk and Memory Caching
  • Priority Requests
  • Support for Request cancellation and parallel downloading

Android Picasso – Loading image from URL

  1. Drawable: Android  Loading image from drawable image into an ImageView
  2. URL: To load an image from  URL, the URL is enclosed as a String inside the load() method
  3. Error: An error drawable is generally used in cases where there’s a failure in loading the image.  inside .error() method.
  4. Callback: Picasso provides callback methods for check of the status of the image loaded (success/error).
    Picasso.with(this).load("").error(R.mipmap.ic_launcher).into(imageView, new Callback() {
                        public void onSuccess() {
                            Log.d("TAG", "onSuccess");
                        public void onError() {
                            Toast.makeText(getApplicationContext(), "An error occurred", Toast.LENGTH_SHORT).show();
  5. Resize: Picasso allows  to  resize the image before displaying  an ImageView by invoking  resize() method and passing the width and height in pixels
  6. Rotate: To rotate an image pass the float value inside the rotate() method.
  7. Scale: Resizing an image can cause stretched images. To keep the aspect ratio intact use centerCrop() or centerInside() with the resize() method.
    fit() is like a delayed resize(), that reduces the image to fit the ImageView bounds.
  8.  centerCrop and centerInside can’t be used without calling resize() with a positive width and height
  9. Targets:  Targets are an interface that would return the bitmap image along with its placeholder and error drawable(if defined). We can further customize the bitmap image returned in the method onBitmapLoaded() or directly show it in the ImageView


You may also like...