compose text
时间: 2024-01-19 16:17:16 浏览: 31
以下是两个关于Compose Text的例子:
1. 监听Text布局信息:
```kotlin
@Composable
fun TextTestView() {
val content = "Hello Compose!"
Column(Modifier.fillMaxSize()) {
Text(
text = content,
onTextLayout = { layoutResult ->
Log.i("Compose Text", "Content:${layoutResult.layoutInput.text}")
Log.i("Compose Text", "Size:${layoutResult.size}")
Log.i("Compose Text", "LineCount:${layoutResult.lineCount}")
}
)
}
}
```
2. 设置Text样式:
```kotlin
@Composable
fun TextTestView() {
val content = "Hello Compose!"
Column(Modifier.fillMaxSize()) {
Text(
text = content,
style = TextStyle(fontFeatureSettings = "smcp")
)
}
}
```