0

I have tried to change ProfilePictureView to circle image with drawable. But it is not working.

Here is my xml for ProfilePictureView

     <com.facebook.login.widget.ProfilePictureView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/profilePicture" />

Here is my drawable file circle.xml

    <?xml version="1.0" encoding="utf-8"?>

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

    <solid
        android:color="#666666"/>

    <size
        android:width="120dp"
        android:height="120dp"/>
</shape>

Here is the function

        profilePictureView = view.findViewById(R.id.profilePicture);
        profilePictureView.setProfileId(userId);
        profilePictureView.setBackgroundResource(R.drawable.circle);
Janna
  • 1

1 Answers1

0

Have a look at this answer. They provide an edited ProfilePictureView class that you can use which applies a rounding effect to the image associated with the profile id.

Something that I feel was missed in the answer above is that you will need to change the namespace declaration in Java and in XML to point to the location of the new file.

In XML this would mean changing:

<com.facebook.login.widget.ProfilePictureView
    ...
/>

to:

<com.myapp.mypackage.view.ProfilePictureView
    ...
/>

After changing the import statement in Java, all you must do is provide the profile id.

profilePictureView = view.findViewById(R.id.profilePicture);
profilePictureView.setProfileId(userId);
Charlie
  • 2,876
  • 19
  • 26