我无法使用这个库将我的一张图片动态地变成一个圆圈。这是我的尝试:
private void drawerSetup() {
Profile profile = Profile.getCurrentProfile();
ProfilePictureView profilePictureView = (ProfilePictureView) findViewById(R.id.profile_image);
CircularImageView circularProfilePicture = (CircularImageView) findViewById(R.id.profile_image_circle);
if(profilePictureView != null) {
profilePictureView.setProfileId(profile.getId());
ImageView imageView = ((ImageView)profilePictureView.getChildAt(0));
Bitmap bitmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
circularProfilePicture.setImageBitmap(bitmap);
}
}
布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="200dp"
xmlns:facebook="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/tools"
android:background="@drawable/side_nav_bar"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:orientation="vertical"
android:gravity="bottom"
app:showIn="@layout/activity_news_feed">
<com.facebook.login.widget.ProfilePictureView
android:id="@+id/profile_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
facebook:com_facebook_preset_size="normal"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:paddingBottom="8dp"
android:layout_centerInParent="true" />
<com.mikhaellopez.circularimageview.CircularImageView
android:layout_width="100dp"
android:layout_height="100dp"
app:border_color="#EEEEEE"
app:border_width="2dp"
app:shadow="true"
app:shadow_radius="10"
android:id="@+id/profile_image_circle"
app:shadow_color="#000000"
android:layout_alignBottom="@+id/profile_image"
android:layout_toLeftOf="@+id/profile_image"
android:layout_toStartOf="@+id/profile_image" />
我知道当我在我的布局profilePictureView
上调用时我的显示正确,它显示正确。profilePictureView.setProfileId(profile.getId());
但是,当我尝试调用circularProfilePicture 时,我只是得到一张“空”照片。图像的位图似乎没有被正确识别/设置。图像不显示profilePictureView
。任何想法为什么会发生这种情况?