小编Tah*_*sif的帖子

Jetpack Compose 减少选项卡的内部填充

我想减少单个选项卡的填充。下图显示了我想要的:

1

我得到什么:

2

我目前正在使用版本 0.16.0 的“accompanist-pager”和“accompanist-pager-indicators”。

代码:

@Composable
fun Tabs(tabNames: List<String>, pagerState: PagerState, scrollToPage: (Int) -> Unit) {
  TabRow(
    selectedTabIndex = pagerState.currentPage,
    backgroundColor = Color.White,
    contentColor = Color.Black,
    divider = {
      TabRowDefaults.Divider(
        thickness = 4.dp
      )
    },
    indicator = { tabPositions ->
      TabRowDefaults.Indicator(
        modifier = Modifier.customTabIndicatorOffset(tabPositions[pagerState.currentPage]),
        height = 4.dp,
        color = EmeraldTheme.colors.primary
      )
    }
  ) {
    tabNames.forEachIndexed { index, name ->
      Tab(
        text = {
          Text(
            text = name,
            maxLines = 1,
            style = globalSearchDefaultTextStyle,
            fontWeight = if (pagerState.currentPage == index) …
Run Code Online (Sandbox Code Playgroud)

tabs android android-tabs android-jetpack-compose

11
推荐指数
2
解决办法
6144
查看次数