wasabeef / glide-transformations

An Android transformation library providing a variety of image transformations for Glide.
Apache License 2.0
9.9k stars 1.41k forks source link

RoundedCornersTransformation not working with center crop #128

Closed Virendra-Varma closed 6 years ago

Virendra-Varma commented 6 years ago

My xml code is

`<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/bg_normal_chat_gray" android:layout_gravity="end" android:layout_marginEnd="9dp" android:elevation="0dp" android:orientation="vertical"

  <ImageView
      android:id="@+id/img_multipurpose"
      android:layout_width="match_parent"
      android:layout_height="120dp"
      android:visibility="visible"
      android:contentDescription="@string/location_image"
      android:layout_marginTop="@dimen/spacing_medium"
      android:layout_marginEnd="@dimen/spacing_medium"
      android:scaleType="centerCrop"
      android:layout_marginStart="@dimen/spacing_medium"
      android:src="@drawable/dummy_picture"
      />
  <TextView
      android:id="@+id/txt_message"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:padding="@dimen/spacing_large"
      android:text="@string/dummy_text"
      android:textColor="@color/white"
      />
</LinearLayout>`

In adapter java

`MultiTransformation multi = new MultiTransformation<>( new RoundedCornersTransformation(64, 0, RoundedCornersTransformation.CornerType.TOP));

GlideApp.with(mActivity) .load(url) .transform(multi).into(mView.mImageView);`

roundcornerissue

I tried So may ways but not successed

LarsEliasNielsen commented 6 years ago

You have to do all your transformation, including the centerCrop, with Glide to fix your issue:

MultiTransformation multi = new MultiTransformation<>(
    new CenterCrop(),
    new RoundedCornersTransformation(64, 0, RoundedCornersTransformation.CornerType.TOP));

GlideApp.with(mActivity)
    .load(url)
    .transform(multi).into(mView.mImageView);

This means that you can remove the scaleType from your layout XML.

Virendra-Varma commented 6 years ago

Thank you @LarsEliasNielsen