android 如何在Jetpack编写中删除TabRow的取消下划线?

nxagd54h  于 2023-03-11  发布在  Android
关注(0)|答案(2)|浏览(186)

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

我只想买选定的颜色。

pbwdgjma

pbwdgjma1#

设置TabRow的除法器参数为divider={},默认为

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

tf7tbtn22#

如果你升级到材料3,除法器的答案不再起作用。用同样的方法改变指示器对我起作用。

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

       }
) { }

相关问题