简体   繁体   English

如何将ProfilePictureView更改为圆形图像。 可绘制不起作用

[英]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.

相关问题 如何更改Facebook SDK的ProfilePictureView小部件的半径? - How to change the radius of ProfilePictureView widget of Facebook SDK? Facebook ProfilePictureView显示圆形图像 - Facebook ProfilePictureView display Circular image 更改profilepictureview的大小:Facebook:preset_size无效 - change the size of the profilepictureview : Facebook:preset_size has no effect Android:如何在com.facebook.widget.ProfilePictureView上放置圆角 - Android: how to put rounded corners on com.facebook.widget.ProfilePictureView 如何更改Facebook分享按钮图像? - How can I change facebook share button image? 如何将tumblr og:image更改为至少200x200? - How can I change a tumblr og:image to be at least 200x200? 如何在Facebook发送对话框中更改捕获的图像,标题和描述 - How can I change captured image, title and description in Facebook send dialog 进行Facebook登录时,如何更改“ fb:login-button”的图像 - how can i change image for “fb:login-button” when doing facebook login 如何使用图形API将图像从可绘制文件夹发布到Facebook? - How to post image from drawable folder to facebook with graph api? 如何使用Facebook SDK中的ProfilePictureView在android应用中显示已登录用户的个人资料图片? - How to display logged in user's profile picture in android app using ProfilePictureView from Facebook SDK?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM