【发布时间】:2021-10-01 21:52:02
【问题描述】:
我有一个来自documentation 的 Kotlin 上的简单 Jetpack Compose 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
)
}
【问题讨论】:
-
我可能需要更改 Tab 的 interactionSource 字段
-
还有其他想法吗?
标签: android kotlin android-jetpack-compose android-jetpack