bumptech / glide

An image loading and caching library for Android focused on smooth scrolling
https://bumptech.github.io/glide/
Other
34.64k stars 6.12k forks source link

setting large .placeholder() leads to vertically stretched image #1269

Closed bluevoidnl closed 8 years ago

bluevoidnl commented 8 years ago

Glide Version:3.7.0

Integration libraries: N/A

Device/Android Version:multiple devices, Samsung Galaxy Tab 3SM-T320, 4.4.2

Issue details / Repro steps / Use case background:

i have a placeholder of 400 by 507 (X x Y) pixels, most images loaded are this size, some are less wide, some less tall. Problem is with the less tall (oblong) images: 400 by 300 pixels. Sometimes (not always!) these are stretched to the full size (507 by 400 pixels). The problem seems to be in the animation code as setting .dontAnimate() resolves the problem. Also removing the placeholder resolves the problem.

It is like the size of the place holder is used for the animated image. I checked this by loging the size of the drawable that is set on the imageview (by subclassing and logging the method setDrawable()) The drawable that is inserted is 507 pixels high when it is shown wrong (streched) and 300 pixels high when it is shown correct.

The problem does not occur on our less wide images.

Glide load line / GlideModule (if any) / list Adapter code (if any): RecyclerView.Adapter

Glide.with(navigationActivity)
                .load(url) //string url
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .placeholder(R.drawable.cover_placeholder) 
                .into(holder.myImageView); // RecyclerView.ViewHolder with imageview

Layout XML:

 <ImageView
            android:id="@+id/fragment_overview_my_image_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_gravity="center"
            android:scaleType="fitCenter"
            />

Stack trace / LogCat:

none
TWiStErRob commented 8 years ago

Dupe of #363, caused by Android's TransitionDrawable, different workarounds in comments and related issues there.