Naman
Naman

Reputation: 97

Change the Layout in Jetpack Compose

PROBLEM ::: I want to change the layout, more specifically hide or show the components in the layout based on the user click events.

I have attached a screen recording of the final result. PLEASE VISIT THIS LINK FOR FINAL RESULT

THINGS WHICH I CAN TRY ::: Create same layout with components and load that layout when user clicks on button. But I know it's the very inefficient way.

Upvotes: 0

Views: 544

Answers (1)

Mehdi.ncb
Mehdi.ncb

Reputation: 372

you can create a isVisible value and add the layout between an if braces.

val isVisible = remember { mutableState(false) }
if (isVisible) {
  content()
}
Button(onClick = { isVisible.value = true })

Upvotes: 2

Related Questions