Home > Mobile >  Change the Layout in Jetpack Compose
Change the Layout in Jetpack Compose

Time:11-02

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.

CodePudding user response:

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 })
  • Related