简体   繁体   English

如何使选项卡在撰写中可滚动

[英]How to make tabs scrollable in compose

I want to add dynamic tab items.我想添加动态选项卡项。 in a scrollable way, not fixed tabs以可滚动的方式,而不是固定的标签

I followed this examplehere在这里按照这个例子

But after I implement the same, still the tabs fixed, what I want is to show the whote text of the tab (Not fixed size tab), and the tabs must be scrollable like the following image但是在我实现相同之后,选项卡仍然是固定的,我想要的是显示选项卡的全文(不是固定大小的选项卡),并且选项卡必须像下图一样可滚动

在此处输入图像描述

I tried to make the TabRaw scrollable as the following:我尝试使 TabRaw 可滚动,如下所示:

 TabRow(
    selectedTabIndex = pagerState.currentPage,
    backgroundColor = Color.Transparent,
    modifier = Modifier
        .fillMaxWidth()
        .padding(MaterialTheme.spacing._20sdp)
        .horizontalScroll(scrollableState)
        .height(32.dp),
    contentColor = colorResource(id = R.color.primary)
)

But it throws IllegalArgumentException, Because I'm including it in a ConstraintLayout但它抛出 IllegalArgumentException,因为我将它包含在 ConstraintLayout 中

I only used ScrollableTabRow instead of TabRow我只使用 ScrollableTabRow 而不是 TabRow

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM