I am trying to get the profile pic of a user from FB and display it in a circular image on my app.I am able to retrieve and display the display pic in ProfilePictureView wid
I spent quite a bit of time investigating the options for displaying a circular Facebook profile image and I think it's easiest to leave the Android SDK aside and just leverage your existing image library's transformations.
Instead of using Facebook's ProfilePictureView
, use ImageView
. Then, load the image with Picasso, Glide, or whatever library you prefer. Below I'm using Picasso with Picasso-Transformations.
Now:
ImageView profilePic = (ImageView) findViewById(R.id.ivProfilePic);
Picasso.with(this)
.load("https://graph.facebook.com/v2.2/" + user.getUserId() + "/picture?height=120&type=normal") //extract as User instance method
.transform(new CropCircleTransformation())
.resize(120, 120)
.into(profilePic);
Before:
ProfilePictureView profilePic = (ProfilePictureView)findViewById(R.id.ivProfilePic);
profilePic.setProfileId(user.getUserId());
//custom transformation code