У меня возникла проблема с использованием этой библиотеки, чтобы сделать одно из моих изображений в круге динамически. Вот моя попытка:Как создать круговое изображение профиля facebook
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());
На моей схеме он отображается правильно. Однако, когда я пытаюсь вызвать circleProfilePicture, я просто получаю «пустую» фотографию. Похоже, что растровое изображение для изображения не распознается/правильно установлено. Изображение не отображается, как это делает profilePictureView
. Любые идеи, почему это может произойти?
который вы использовали? Всегда ставьте много информации, насколько это возможно. Кроме того, вы заглянули в logcat? есть ли какое-то исключение? –
http://stackoverflow.com/questions/23464707/display-fb-profile-pic-in-circular-image-view-in-application –
Похоже, что он ждет ответа на изображение. попытайтесь получить изображение после задержки. –