coil-kt / coil

Image loading for Android and Compose Multiplatform.
https://coil-kt.github.io/coil/
Apache License 2.0
10.78k stars 660 forks source link

The aspect ratio of Placeholder and ImageView is different, which leads to display BUG #607

Closed Khaos116 closed 2 years ago

Khaos116 commented 3 years ago

Use Placeholder image No Placeholder image

Khaos116 commented 3 years ago

Coil version is 1.1.0 PlaceHolder size is 720*1280

colinrtwhite commented 3 years ago

@caiyoufei It's not clear what the bug and expected behaviour here is. Please include a sample app that reproduces the issue. I would also ensure your ConstraintLayout version is the latest as there have been a number of patch releases with sizing fixes.

Khaos116 commented 3 years ago

I found the cause of this problem, because layer-list was used as a placeholder。Demo url is : https://github.com/khaos116/CoilHolderBug

Khaos116 commented 3 years ago

image

colinrtwhite commented 3 years ago

Thanks for the sample! I'll take a look at it this week.

destructo570 commented 3 years ago

I am facing this issue as well. After scrolling off the image from the screen and scrolling back to that image shows the correct aspect ratio. For now I have disable placeholder image. Is there any fix planned for this?

colinrtwhite commented 3 years ago

Still figuring out the best way to address this without unexpected behaviour changes for existing users. In the meantime to work around the issue set precision(Precision.EXACT) on either your request or your image loader.

coconut85 commented 3 years ago

Facing the same issue as well. ImageView with android:adjustViewBounds="true" and android:scaleType="fitXY" in a RecyclerView with a placeholder. ImageView keeps the placeholder aspect ratio.

Tried to add size(OriginalSize) and precision(Precision.EXACT) but didn't fix. Works well without a placeholder.

<ImageView
  android:layout_marginTop="10dp"
  android:adjustViewBounds="true"
  android:layout_gravity="center_horizontal"
  android:id="@+id/ivGif"
  android:scaleType="fitXY"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"/>
view.ivGif.load(File(gifPath)) {
  crossfade(true)
  size(OriginalSize)
  precision(Precision.EXACT)
  placeholder(R.drawable.gif_loading_placeholder)
}
yaseen2591 commented 3 years ago

I'm experiencing a same issue as well. sadly precision(Precision.EXACT) didn't help me to fix the issue.

  <ImageView
      android:layout_width="0dp"
      android:layout_height="0dp"
      android:scaleType="fitXY"
      android:id="@+id/view_gif"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      bind:layout_constraintDimensionRatio="@{model.ratio}"
      bind:imageURL="@{model.url}"/>

I also set precision(Precision.EXACT) on Request builder

xanscale commented 3 years ago

same problem here using placeholder break final image size (even with imageview with fixed sizes)

Ecgbert commented 3 years ago

I was facing the same problem. My solution was to implement a custom imageview to control the aspect ratio and to stop using constraintDimensionRatio.

colinrtwhite commented 2 years ago

This is fixed in Coil 2.0.0.