如何在 Jetpack Compose 中删除 TabRow 的下划线?

问题描述 投票:0回答:2

我好累,把

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)
                        }
                    }
                )
            }
        }
    )
}

我只想拥有选择的颜色

android android-jetpack-compose android-tabs
2个回答
7
投票

TabRow
的分频器参数设置为
divider={}
。默认一个是

divider: @Composable () -> Unit = @Composable {
    Divider()
}

0
投票

如果升级到材料 3,分隔符答案将不再有效。以同样的方式更改指示器对我有用。

TabRow(
       selectedTabIndex = selectedTab.ordinal,
       containerColor = Color.White,
       indicator = {

       }
) { }
© www.soinside.com 2019 - 2024. All rights reserved.