As CommonsWare stated, compose being a declarative toolkit you tie your component to a state (for ex: isVisible
), then compose will intelligently decide which composables depend on that state and recompose them. For ex:
@Composable
fun MyText(isVisible: Boolean){
if(isVisible){
Text(text = stringResource(id = R.string.hello))
}
}
Also you could use the AnimatedVisibility()
composable for animations.