Skip to content Skip to sidebar Skip to footer

Glide Circular Image Gets Cropped

I'm trying to make a circular imageview using glide... I followed this tutorial How to round an image with Glide library? but my image always get the top and bottom cropped i tri

Solution 1:

<ImageView
                android:id="@+id/profileImageView"
                android:layout_width="200dp"
                android:layout_height="200dp"
                android:layout_gravity="center"
                android:layout_margin="15dp"
                android:scaleType="fitXY" />

The problem is that is overlaping the other views, with a margin it should solve your problem

Solution 2:

Glide.with(context)
    .load("https://yourImageUrl.jpg")
    .apply(newRequestOptions().circleCrop())
    .into(headerImage);

Solution 3:

Try This

Add xml layout:

<RelativeLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:padding="1dp"android:id="@+id/lay_profpic"android:layout_gravity="center"android:layout_margin="20dp"android:background="@drawable/border_circle"><ImageViewandroid:id="@+id/profile_picture"android:scaleType="centerCrop"android:layout_centerHorizontal="true"android:src="@color/white"android:layout_gravity="center"android:layout_width="90"android:layout_height="90dp" /></RelativeLayout>

Add Java code use Glide

Glide.with(this)
                .load(user.getProfilePicture())
                .transform(new CircleTransform(this))
                .into(new GlideDrawableImageViewTarget(ivProfilePicture) {
                    @Override
                    public void onResourceReady(GlideDrawable drawable, GlideAnimation anim) {
                        super.onResourceReady(drawable, anim);
                        ivProfilePicture.setImageDrawable(drawable);
                        ivProfilePicture.invalidate();
                        ivProfilePicture.requestLayout();
                    }
                });

Post a Comment for "Glide Circular Image Gets Cropped"