I want to set background of a column as image instead of color.
We set the background color as this
Column(modifier = Modifier.background(Colors.Blue) )
so instead of this, I want to use an image to set as background.
I tried setting it using painter of the modifier.
val painter = rememberAsyncImagePainter( "imageUrl",contentScale = ContentScale.FillHeight)
Column(modifier = Modifier.paint(painter) )
But this is not setting the image to the complete column height and width.
Is there any way I can set the image directly to the column composable instead of using Box and other composables? I am using coil to download the image
You can use the paint
modifier applying the contentScale
.
Something like:
val painter = rememberAsyncImagePainter(
model = ImageRequest.Builder(LocalContext.current)
.data(url)
.size(ORIGINAL)
.build(),
contentScale = ContentScale.FillBounds
)
Column(
Modifier
.fillMaxSize()
.paint(
painter,
contentScale = ContentScale.FillBounds
)
) {
//content....
}