caxapexac
caxapexac

Reputation: 914

Glide transition breaks transform

I want to make rounded corners on my image with placeholder transition. (other SO answers are about rounded corners without translation, don't mark duplicate)

This code makes rounded corners:

Glide
    .with(itemView.context)
    .load(imgUrl)
    .transform(CenterCrop(), RoundedCorners(radius))
    .placeholder(R.drawable.default_image)
    .into(itemView.image)

This code doesn't make it (when I add transition):

Glide
    .with(itemView.context)
    .load(imgUrl)
    .transform(CenterCrop(), RoundedCorners(radius))
    .placeholder(R.drawable.default_image)
    .transition(DrawableTransitionOptions().crossFade()) // There
    .into(itemView.image)

What am I doing wrong?

UPD: image xml:

<ImageView
    android:id="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:contentDescription="@string/cd_event_image"
    android:scaleType="fitCenter"
    tools:srcCompat="@drawable/default_image" />

Upvotes: 1

Views: 748

Answers (1)

caxapexac
caxapexac

Reputation: 914

Solved using rounded corner shape placeholder instead of image (rectange of the placeholder hided rounded corner):

Glide
    .with(itemView.context)
    .load(imgUrl)
    .placeholder(R.drawable.shape_rounded)
    .transition(DrawableTransitionOptions().crossFade())
    .transform(RoundedCorners(radius))
    .into(itemView.image)

shape_rounded:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="@dimen/event_corners_radius" />
    <solid android:color="@color/rdColorMainBackground"/>
</shape>

Upvotes: 2

Related Questions