android-jetpack-compose - 即使没有填充整个空间喷气背包,底部导航栏标签也会被剪裁到下一行
问题描述
如何在不破坏单行的情况下制作图标标签,减小字体大小有帮助但变小使阅读变得困难。
底部导航实现:
BottomNavigation(backgroundColor = Color.White) {
items.forEach { item ->
BottomNavigationItem(
selected = currentRoute == item.route,
onClick = { /*TODO*/ },
icon = {
if (currentRoute == item.route) ActiveIcon(item.activeIcon)
else Icon(painterResource(item.disableIcon), null)
},
label = {
Text(
stringResource(item.title), // Label
fontWeight = FontWeight.SemiBold
)
},
)
}
}
解决方案
softWrap
在您的文本上使用并将其设置为 false:
BottomNavigation(backgroundColor = Color.White) {
items.forEach { item ->
BottomNavigationItem(
selected = currentRoute == item.route,
onClick = { /*TODO*/ },
icon = {
if (currentRoute == item.route) ActiveIcon(item.activeIcon)
else Icon(painterResource(item.disableIcon), null)
},
label = {
Text(
stringResource(item.title), // Label
fontWeight = FontWeight.SemiBold,
softWrap = false
)
},
)
}
}
注意:BottomNavigation 不可滚动,因此如果导航栏中的项目数量过多,文本将被剪裁在超出选项卡宽度的项目上。这是设计使然。
推荐阅读
- java - HTTP POST Angular 到 Java。无法发送不同类型的多个参数
- docker - 在容器上运行 docker 映像时,找不到 restart.sh 文件
- java - 为什么我可以在 Groovy 的 List 接口中使用方法 'each'?
- jenkins - 如何以编程方式将插件添加到詹金斯
- excel - Application.CommandBars("vbaPopup").ShowPopup ··· 如何添加`Submenu` (Ron de Bruin)?
- reactjs - 带有 flex 的 instagram 中的新闻提要只有 8 个孩子?
- ruby-on-rails - 在 Rails 中扩展资源路径
- python - 尝试在 desktop.ini 文件上写入时如何修复 Python 中的 PermissionError?
- python - 在Python中计算两个数字之间不匹配的共享数字
- excel - 如何使高级过滤器将一行数据复制到范围?