Jetpack Compose
Examples
To add a Composable
, use the compose
method.
compose("Text") {
Text(text = "Hello, World")
}
You can use state in the compose
.
compose("MyComponent") {
var boolean by remember {
mutableStateOf(true)
}
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = if (boolean) "Hello" else "World"
)
Button(
onClick = { boolean = !boolean }
) {
Text(text = "Toggle")
}
}
}
Parameters
name | description |
---|---|
name | The UI Component name. |
definition | Composable function. |