如何在单行中制作图标标签而不破坏它,减小字体大小有帮助,但变小会难以阅读。
底部导航实现:
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
)
},
)
}
}
Run Code Online (Sandbox Code Playgroud)
在您的文本上使用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
)
},
)
}
}
Run Code Online (Sandbox Code Playgroud)
注意:BottomNavigation 不可滚动,因此如果导航栏中的项目数量太多,文本将在超出选项卡宽度的项目上被剪裁。这是设计使然。
| 归档时间: |
|
| 查看次数: |
2084 次 |
| 最近记录: |