[英]How can I change ProfilePictureView to circle image. Drawable is not working
I have tried to change ProfilePictureView to circle image with drawable. 我试图将ProfilePictureView更改为可绘制的圆形图像。 But it is not working.
但这是行不通的。
Here is my xml for ProfilePictureView 这是我的ProfilePictureView的xml
<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 这是我的可绘制文件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);
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. 它们提供了一个可编辑的
ProfilePictureView
类,您可以使用该类对与配置文件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. 我在上面的答案中遗漏了一些东西,那就是您将需要更改Java 和 XML中的名称空间声明,以指向新文件的位置。
In XML this would mean changing: 在XML中,这意味着更改:
<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. 更改Java中的import语句后,您所要做的就是提供配置文件ID。
profilePictureView = view.findViewById(R.id.profilePicture);
profilePictureView.setProfileId(userId);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.