Bar*_*fet 1 android android-jetpack-compose
我想更改SelectionContainer的颜色,但在参数部分中没有看到任何可以在此处进行更改的选项。我还查看了内部代码,但看不到任何与颜色相关的内容。文档没有提到这一点。
问题:有没有办法改变选择颜色,或者这是不可能的?
您可以使用TextSelectionColors设置所选内容的颜色。
为此,您需要将您的内容包装Text在CompositionLocalProvider. 文本和文本字段组件用于文本选择的颜色由LocalTextSelectionColors.current提供。
您可以TextSelectionColors使用以下方式提供自定义:
val customTextSelectionColors = TextSelectionColors(
handleColor = Red,
backgroundColor = Red.copy(alpha = 0.4f)
)
CompositionLocalProvider(LocalTextSelectionColors provides customTextSelectionColors) {
SelectionContainer {
Text(
text = coin.description,
style = MaterialTheme.typography.body2
)
}
}
Run Code Online (Sandbox Code Playgroud)
PS 问题的一部分是从这个 SO 答案复制的 -链接
| 归档时间: |
|
| 查看次数: |
2343 次 |
| 最近记录: |