Pablo
09/24/2024, 5:28 PMImage(
bitmap = bitmap,
null,
modifier = Modifier.fillMaxWidth(1f).background(Color.Red),
contentScale = ContentScale.Fit
)
And I can see that an empty red space is on left and right sides of the image... so the view is filling the entire size but not the image itself. Any idea of what is happening?Zach Klippenstein (he/him) [MOD]
09/24/2024, 5:30 PMFit
will try to fit the whole image in the bounds. Try FillWidth
?Pablo
09/24/2024, 5:48 PMPablo
09/24/2024, 5:49 PMZach Klippenstein (he/him) [MOD]
09/24/2024, 5:49 PMPablo
09/24/2024, 5:49 PMZach Klippenstein (he/him) [MOD]
09/24/2024, 5:49 PMFillWidth
works – it scales to fill and might cropPablo
09/24/2024, 5:49 PMPablo
09/24/2024, 5:50 PMPablo
09/24/2024, 5:50 PMPablo
09/24/2024, 5:50 PMZach Klippenstein (he/him) [MOD]
09/24/2024, 5:51 PMPablo
09/24/2024, 5:51 PMPablo
09/24/2024, 5:51 PMPablo
09/24/2024, 5:51 PMPablo
09/24/2024, 5:52 PMPablo
09/24/2024, 5:52 PMPablo
09/24/2024, 5:52 PMZach Klippenstein (he/him) [MOD]
09/24/2024, 6:03 PMFillWidth
is cropping, and that makes it sound like there's not enough height.Pablo
09/24/2024, 6:15 PMPablo
09/24/2024, 6:16 PMPablo
09/24/2024, 6:16 PMPablo
09/24/2024, 6:16 PMZach Klippenstein (he/him) [MOD]
09/24/2024, 6:17 PMPablo
09/24/2024, 6:17 PMPablo
09/24/2024, 6:18 PMPablo
09/24/2024, 6:18 PMChrimaeon
09/24/2024, 6:44 PMZach Klippenstein (he/him) [MOD]
09/24/2024, 7:18 PMZach Klippenstein (he/him) [MOD]
09/24/2024, 7:19 PMZach Klippenstein (he/him) [MOD]
09/24/2024, 7:20 PMZach Klippenstein (he/him) [MOD]
09/24/2024, 7:20 PMModifier.verticalScroll
on the image.Zach Klippenstein (he/him) [MOD]
09/24/2024, 7:23 PMbut coming back to my question, why Fillwidth works and Fit not? maybe if I use a image with more height than width I can get problems if using fillWidthJust from reading the documentation, it's because
Fit
will not scale the image larger than it can fit in both dimensions. In your case it seems it maxed out the height before it got to the full width. The docs say, "the image is scaled up to fit the bounds." That means "fit the bounds" in both dimensions.
FillWidth
worked because it doesn't care about height. The docs say "so that the bounds match the destination width" and the example given on the docs page show an image that is too tall for the available space being cropped and centered so that the width matches.Pablo
09/24/2024, 8:35 PMPablo
09/24/2024, 8:35 PMPablo
09/24/2024, 8:35 PMPablo
09/24/2024, 8:35 PMPablo
09/24/2024, 8:35 PMPablo
09/24/2024, 8:36 PMZach Klippenstein (he/him) [MOD]
09/24/2024, 8:36 PMPablo
09/24/2024, 8:36 PMPablo
09/24/2024, 8:37 PMPablo
09/24/2024, 8:37 PMPablo
09/24/2024, 8:37 PMZach Klippenstein (he/him) [MOD]
09/24/2024, 8:38 PMPablo
09/24/2024, 8:38 PMZach Klippenstein (he/him) [MOD]
09/24/2024, 8:38 PMPablo
09/24/2024, 8:38 PMPablo
09/24/2024, 8:39 PM