as a background of a modifier in compose? In java, it was done like this:
layout.setBackground(bg.getDrawable());
a
andylamax
10/15/2024, 5:41 PM
use a Box, then place an image in that box, then overlay the image with your desired UI
☝🏼 1
p
Pablo
10/16/2024, 8:28 AM
well, it's a bit more complicated, It's a LazyColumn, and it haves some items. Ok, I need the drawable to be the background of the LazyColumn
Pablo
10/16/2024, 8:29 AM
so, how can I do that using a Box? I suppose you mean placing a Image inside the Box, but the drawable must be the exact size of the LazyColumn, so I don't know how to do that, can you help me?
Pablo
10/16/2024, 4:06 PM
@andylamax maybe using onGloballyPositioned ? it seems to be a very rude way, I hope you know a correct way
a
andylamax
10/16/2024, 10:04 PM
Does't this snippet work?
Copy code
@Composable
fun ComponentWithBackGround() {
Box(modifier = Modifier.fillMaxSize()) {
Image(..., modifier.fillMaxSize())
LazyColumn(modifier = Modifier.fillMaxSize()) {
// you code goes here
}
}
}
p
Pablo
10/17/2024, 5:54 AM
well, maybe I didn't explain myself correctly, I don't wanna have the drawable filling the entire height of the screen
Pablo
10/17/2024, 5:55 AM
if the lazycolumn has only 2 or 3 items, will have only a portion of the height of the screen
Pablo
10/17/2024, 5:55 AM
so @andylamax the drawable should be the same size, not the entire screen height