Created
August 31, 2023 04:42
-
-
Save Farhandroid/e3c94d77917308f67bdd229f2f31255c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun AnimatedVisibilityExample() { | |
// State to control the visibility of the text | |
var isVisible by remember { mutableStateOf(true) } | |
// Box to layer the button and the text | |
Box( | |
contentAlignment = Alignment.Center, | |
modifier = Modifier.fillMaxSize() | |
) { | |
// Button to toggle the visibility | |
Button(onClick = { isVisible = !isVisible }) { | |
Text("Toggle Visibility") | |
} | |
// AnimatedVisibility to control the appearance of the text | |
AnimatedVisibility( | |
visible = isVisible, | |
enter = fadeIn(), | |
exit = fadeOut() | |
) { | |
// The text to show/hide | |
Text("Hello, World!", modifier = Modifier.padding(top = 80.dp)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment