0

在此处输入图像描述

我的文本宽度有问题Tab()- 它跳到下一行。当我设置maxLines = 1文本被切断。如何使项目的重量取决于文本的长度?

TabRow(
                                modifier = Modifier.fillMaxWidth(),
                                selectedTabIndex = selectedIndex.value,
                                indicator = indicator
                            ) {
                                tabs.forEachIndexed { index, category ->
                                    Tab(
                                        modifier = Modifier
                                            .wrapContentWidth()
                                            .background(MaterialTheme.colors.onBackground),
                                        selected = index == selectedIndex.value,
                                        onClick = {
                                            selectedIndex.value = index; viewModel.actions.trySend(
                                            ProductDetailAction.SelectTab(
                                                tabs[selectedIndex.value]
                                            )
                                        )
                                        },
                                        text = {
                                            Text(
                                                text = when (category) {
                                                    TabCategory.Opinion -> stringResource(R.string.opinions)
                                                    TabCategory.Information -> stringResource(R.string.informations)
                                                    TabCategory.Videos -> stringResource(R.string.movies)
                                                    TabCategory.Questions -> stringResource(R.string.questions)
                                                },
                                                color = MaterialTheme.colors.primary,
                                                fontWeight = FontWeight.Normal,
                                                fontSize = 13.sp,
                                                softWrap = false,
                                                maxLines = 1
                                            )
                                        }
                                    )
                                }
                            }
4

0 回答 0