Using picasso library with a circle image view

MichaelStoddart picture MichaelStoddart · Jun 5, 2015 · Viewed 26.3k times · Source

I am looking at using the Picasso library to download an image from URL and pass this into circle image view, but since picasso requires that you pass in an actual imageView I have come to a standstill on how to do it

I am using the picasso library from here http://square.github.io/picasso/ and the circle image view class from here https://github.com/hdodenhof/CircleImageView

Here is the start of my code to get the image

private void getData() {

    userName.setText(prefs.getString("userName",""));
    jobTitle.setText(prefs.getString("profile",""));
    userLocation.setText(prefs.getString("location",""));




    // ??????    

    // Picasso.with(context).load(image link here).into(imageview here);

    //CircleImageView img = new CircleImageView(this);
    //img.setImageResource();
    //img.setImageBitmap();
    //img.setImageDrawable();
    //img.setImageURI();

}

Edit:

here is the xml for the circleImageView

<michael.CircleImageView
 android:layout_width="100dp"
 android:layout_height="100dp"
 android:src="@drawable/shadow"
 android:layout_gravity="center"
 android:layout_marginTop="16dp"
 app:border_width="2dp"
 app:border_color="#274978"
 android:id="@+id/circleImageView"

Answer

Yogesh Narayanan picture Yogesh Narayanan · Jun 5, 2015

I don't think you require CircleImageView library

You can implement Circular Transformation check the below gist

https://gist.github.com/julianshen/5829333

then

Picasso.with(activity).load(image link here)
     .transform(new CircleTransform()).into(ImageView);