Vinay Gaba
03/07/2020, 6:45 AMImagePainter
to display an image. Code in thread..VerticalScroller {
Column(LayoutPadding(16.dp)) {
Text("Load image from the resource folder")
LocalImageComponent(R.drawable.image)
}
}
@Composable
fun LocalImageComponent(@DrawableRes resId: Int) {
val image = loadImageResource(resId)
image.resource.resource?.let {
Box(
modifier = LayoutHeight.Max(200.dp) + ImagePainter(it).toModifier(
scaleFit = ScaleFit.FillWidth
))
}
}
This scales the image to occupy the entire width but the text above ends up not being visible. I am wondering if there's something wrong about how I'm setting the constraints.DrawImage
Clip(shape = RoundedCornerShape(8.dp)) {
Box(modifier = LayoutHeight.Max(200.dp) + ImagePainter(image).toModifier())
}
Kazemihabib1996
03/07/2020, 8:27 AM