gpt4 book ai didi

android - 如何在 Android Jetpack Compose 的 TabRow 中更改按下的 Tab 颜色?

转载 作者:行者123 更新时间:2023-12-04 23:49:06 28 4
gpt4 key购买 nike

我在 Kotlin 上有一个简单的 Jetpack Compose TabRow 示例,来自 documentation ,我刚刚更改了文本和下划线颜色。但是按下选项卡时会有橙色背景色。我想让它透明。
Image of TabRow

var state by remember { mutableStateOf(0) }
val titles = listOf("TOP", "NEW", "HOT")
Column {
TabRow(
contentColor = MaterialTheme.colors.primaryVariant, // This is underline's color
selectedTabIndex = state
) {
titles.forEachIndexed { index, title ->
Tab(
selectedContentColor = MaterialTheme.colors.primaryVariant,
unselectedContentColor = MaterialTheme.colors.secondary,
text = { Text(title) },
selected = state == index,
onClick = { state = index }
)
}
}
Text(
modifier = Modifier.align(Alignment.CenterHorizontally),
text = "Text tab ${state + 1} selected",
style = MaterialTheme.typography.body1
)
}

最佳答案

现在,您可以设置backgroundColor对于这样的标签:

TabRow(
selectedTabIndex = state,
...
backgroundColor = Color.White
)

关于android - 如何在 Android Jetpack Compose 的 TabRow 中更改按下的 Tab 颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69412306/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com