Android NavigationRail显示了项目文本的多个标签行
I'm developing a NavigationRail and I wanted to display the text of each item in two lines, as show in this official example, but it keeps getting ellipsized in the end. I've tried to redefine the applying style but nothing seems to work.
Any help? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据“ nofollow noreferrer”> navigation rail'没有官方方法为项目文本设置多行。但是您可以通过以下示例中的简单解决方法来实现此目标:
1 .define
navigationRailview
在xml中,如下所示:where
@菜单@菜单/navigation_rail_menu 包含以下示例菜单项:
2 。对于每个项目,以编程方式更改最大行数,如以下示例:
其中
setteTiTemmaxlines()
是更改每个项目的辅助功能maxlines
:结果:
As per the Navigation rail - Material Design documentation it seems that there is no an official way to set multiple lines for an item text. But you can achieve this with a simple workaround like in the below example:
1.Define the
NavigationRailView
in xml like the below:where
@menu/navigation_rail_menu
contains the below sample menu items:2.And for each item change the Max number of lines in a programmatically way like in the below example:
where
setItemMaxLines()
is a helper function to change for each Item theMaxLines
:Result: