You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jetpack Compose中如何修改BasicTextField的backgroundColor属性

Jetpack Compose 文本框背景色配置方案

TextField 背景色配置

使用Jetpack Compose的TextField组件时,可通过colors参数直接配置背景色,示例代码如下:

TextField(
    value = text.value,
    onValueChange = { text.value = it },
    colors = TextFieldDefaults.textFieldColors(backgroundColor =  Color.Red)
)

BasicTextField 背景色配置

BasicTextField组件没有提供直接配置backgroundColor的参数,可通过添加Modifier.background()修饰符实现背景色设置,示例代码如下:

BasicTextField(
    value = text.value,
    onValueChange = { text.value = it },
    modifier = Modifier.background(Color.Red)
    // 其他配置参数
)

内容的提问来源于stack exchange,提问作者Artaza Sameen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.01 03:39:03