You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Okay, I figured out that if I manually specify to use a CrossfadeTransition with preferExactIntrinsicSize = true, it works - most likely an issue with me using a sizeless painter as placeholder:
@Composable
privatefunDemoImage(crossfade:Boolean) {
AsyncImage(
model =ImageRequest.Builder(LocalContext.current)
.data("https://fastly.picsum.photos/id/1027/512/512.jpg?hmac=kFBJYzp0Y88x_HGjxrDXixHRgspdPuIO0jIswHYahvY")
.transitionFactory(
if (crossfade) CrossfadeTransition.Factory(
durationMillis =200,
preferExactIntrinsicSize =true
)
elseTransition.Factory.NONE
)
.build(),
imageLoader = imageLoader,
contentDescription =null,
contentScale =ContentScale.Crop,
// Note: Removing the placeholder image will also work around the alignment bug.
placeholder =ColorPainter(Color.Red),
alignment =Alignment.TopCenter,
modifier =Modifier
.aspectRatio(16/9f)
.fillMaxSize(),
)
}
Is this intended behavior, or is it indeed considered a bug?
Describe the bug
When using
AsyncImage
to display an image usingcrossfade
and aplaceholder
, the initial image alignment won't work.To Reproduce
Here is a small demo activity that shows the issue with little effort:
Here is the output. Note that both images actually use the top anchor, but the one with crossfading enabled ignores the anchor:
Version
This was discovered using Version 2.7.0 of Coil for Compose, but is also reproducible using 3.0.4.
The text was updated successfully, but these errors were encountered: