https://kotlinlang.org logo
#compose
Title
# compose
u

ursus

02/05/2023, 10:44 PM
Is there a
Modifier.animateItemPlacement
equivalent for a plain
Column
(not lazy?) i.e. to animate item insertion/deletion in the list? (
animateContentSize
won't do)
Copy code
val players by remember { AppComponent.dao.players() }.collectAsState(emptyList())

Column {
    for (player in players) {
        Text(
            modifier = Modifier
                .fillMaxWidth()
                .wrapContentHeight()
                .padding(16.dp),
            text = "player=$player"
        )
        Divider()
    }
}
I know this could be made a
LazyColumn
but for research purpose let assume not
t

tad

02/05/2023, 11:30 PM
You can use
AnimatedContent
with an empty transition, and
Modifier.animateEnterExit
to simulate the same animation behavior.
u

ursus

02/05/2023, 11:51 PM
animatedcontent where, on the whole column or each item?
t

tad

02/05/2023, 11:53 PM
The whole column
You have to do something like
EnterTransition.None with ExitTransition.None using null
for the transitionSpec, and use that modifier on each child you want animated
u

ursus

02/05/2023, 11:56 PM
but wpuld that animate say deleting from middlr of the list?
t

tad

02/06/2023, 12:00 AM
You can, with an
animateEnterExit
on the deleted child. The animated state would be a list of children (or IDs) to show in the column.
139 Views