https://kotlinlang.org logo
#compose
Title
# compose
m

mgrazianodecastro

03/28/2023, 10:11 PM
how can I scale an picture inside a Box After it has been scaled by the Image composable? This does work, but I have to put the alpha Modifier. Is this intentional (for optimization) or a bug?
Copy code
Box(modifier = Modifier.size(cardWidth, cardHeight)){
    Image(
        // ..
        contentScale = ContentScale.Crop,
        modifier = Modifier.alpha(0.99f).graphicsLayer {
            scaleX = someScale
            scaleY = someScale
        }
    )
}
without the alpha, the whole scaled image is painted, beyond the box size
e

ephemient

03/28/2023, 10:52 PM
also I'd probably choose to do the scaling inside a custom painter instead of involving a graphicsLayer, and then you'd also have control over the clipping
well I guess it depends. if you're changing scaling interactively then graphicsLayer makes sense
m

mgrazianodecastro

03/28/2023, 11:22 PM
hmm, I don't need to scale it dynamically (not right now)
I will look into the other option
3 Views