I want to implement this ui. How can i overlap post list item on each other in android jetpack compose?
Asked
Active
Viewed 7,798 times
4 Answers
19
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
}

Quentin Nivelais
- 331
- 2
- 6
-
thanks a lot! you're a man. – Mohammad Nov 20 '21 at 14:51
8

Ayush Saini
- 180
- 5
-
1Can you explain how to do this? I still can't find an example. – Dragos Rachieru May 25 '21 at 06:24
8
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.

Bagadeshkumar R
- 228
- 3
- 2
0
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.

Victor Lee
- 2,467
- 3
- 19
- 37

Patrice Mulindi
- 1
- 3