androidandroid-jetpack-composeandroid-tabs

How do I remove undeline of TabRow in Jetpack Compose?


I am tiring to remove the underline of TabRow, but did not succeed. Here is the code:

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

enter image description here

I only want to have the selected color.


Solution

  • set divider param of TabRow as divider={}. Default one is

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