bumptech / bumptech/glide

Placeholder messes up Scale / Size

Open
#4,437 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
35k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
8

Description

**Glide Version**: 4.11.0

**Device/Android Version**: Pixel 3a Emulator (Android Q) / Umidigi One Max (Android 9)

**Issue details / Repro steps / Use case background**:
I have an ImageView with
- width: match_parent
- height: wrap_content

I load the image from a URL and use fitCenter so that the ImageView is filled out.
I already loaded the same picture but with a different (smaller) size so I have a drawable.
If I just load the drawable it works as expected (imagesize matches phone width with aspect ratio).
If I only load the link (with the larger version) it also works as desired, but I want the drawable as a placeholder during the loading time.
So if I set the placeholder (drawable) the picture is in its original size (ignores fitCenter) and the picture from the link then also ignores fitCenter

**Glide load line / `GlideModule` (if any) / list Adapter code (if any)**:
```java
Glide.with(this).asDrawable().load(imageDrawable).fitCenter().into(imageview) // works fine
Glide.with(this).asDrawable().load(imageLink).fitCenter().into(imageview) // works fine
Glide.with(this).asDrawable().load(imageLink).placeholder(imageDrawable).fitCenter().into(imageview) // messed up scale / size
```

**Layout XML**:
```xml

```

**Screenshots - Imgur:**
[No Placeholder - Drawable](https://imgur.com/a/2VCmzlx)
[No Placeholder - Link](https://imgur.com/a/2VCmzlx)
[Drawable as Placeholder - Link](https://imgur.com/a/6eSdaOD)

Contributor guide

Open the contributing guide

Research direction

Start with the three Glide load lines and the ImageView XML in the issue, comparing the requests with and without the placeholder. Check how the placeholder and loaded image interact with fitCenter; done means the placeholder and final image both scale as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.