Reputation: 201
I want to implement this ui. How can i overlap post list item on each other in android jetpack compose?
Upvotes: 18
Views: 9444
Reputation: 421
If you're using a Column or a LazyList to display the items, you can use the verticalArrangement parameters with a negative spacedBy space.
LazyColumn(
verticalArrangement = Arrangement.spacedBy((-32).dp)
) {
// Put the items to overlap here
}
Upvotes: 20
Reputation: 1
Adding to Bagadeshkumar R's answer, you can place Spacer with height that is spacer(modifier = Modifier.height(8.dp))
, attribute between image 1 and 2, for image 1 to be partially visible.
Upvotes: 0
Reputation: 240
You can use Box
sample :
Box(modifier = Modifier.fillMaxSize()) {
Image(modifier = Modifier.fillMaxSize()) {} //Image1
Image(modifier = Modifier.fillMaxSize()) {} //Image2
}
In the above example, Image2 will cover the Box's maxSize. Image1 will be beneath Image2.
Upvotes: 8
Reputation: 180
Use Box to put one element on top of another.
Also, read official documentation here
Upvotes: 7