我好累,把
TabRow
的下划线去掉,没成功。这是代码:
@ExperimentalPagerApi
@Composable
fun Tabs(pagerState: PagerState) {
val tabs = listOf(R.string.add, R.string.add)
val scope = rememberCoroutineScope()
val currentPage = pagerState.currentPage
TabRow(
modifier = Modifier
.padding(start = 36.dp, top = 16.dp, end = 36.dp)
.clip(shape = RoundedCornerShape(16.dp)),
selectedTabIndex = currentPage,
backgroundColor = Color.Transparent,
tabs = {
tabs.forEachIndexed { index, tab ->
Tab(
modifier = Modifier.clip(RoundedCornerShape(16.dp)),
text = {
Text(text = stringResource(id = tab))
},
selected = currentPage == index,
onClick = {
scope.launch {
pagerState.animateScrollToPage(index)
}
}
)
}
}
)
}
我只想拥有选择的颜色
将
TabRow
的分频器参数设置为divider={}
。默认一个是
divider: @Composable () -> Unit = @Composable {
Divider()
}
如果升级到材料 3,分隔符答案将不再有效。以同样的方式更改指示器对我有用。
TabRow(
selectedTabIndex = selectedTab.ordinal,
containerColor = Color.White,
indicator = {
}
) { }