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

semoro

04/21/2020, 7:15 PM
Why image corners not being clipped if using
ContentScale.FillWidth
? When image width is bigger then clip area
Copy code
Image(
    asset = image,
    modifier = Modifier.clip(RoundedCornerShape(20.dp)),
    contentScale = ContentScale.FillWidth
)
Copy code
@Composable
fun ImgTest() {

    VerticalScroller {
        Column(Modifier.padding(10.dp).preferredWidth(100.dp)) {


            Stack {
                Image(
                    asset = vectorResource(id = R.drawable.vect),
                    contentScale = ContentScale.FillWidth,
                    modifier = Modifier.clip(RoundedCornerShape(20.dp))
                )
                Text(text = "FillWidth")
            }

            Divider()
            Stack {
                Image(
                    asset = vectorResource(id = R.drawable.vect),
                    contentScale = ContentScale.FillHeight,
                    modifier = Modifier.clip(RoundedCornerShape(20.dp))
                )
                Text(text = "FillHeight")
            }
        }
    }

}
vect.xml - simple image with 200dp/200dp size
3 Views