简体   繁体   English

导航抽屉菜单中的多行文本

[英]Multiple line text in navigation drawer menu

I am trying to wrap my text in a nav-tab It doesn't display everything if the phone isn't horizontal我正在尝试将我的文本包装在导航标签中如果手机不是水平的,它不会显示所有内容

Here is my xml code fot the nav tab:这是我的导航选项卡的 xml 代码:

<group android:checkableBehavior="single">
    <item
        android:id="@+id/nav_scan"
        android:icon="@drawable/ic_menu_camera"
        android:title="@string/nav_option_scannen" />
    <item
        android:id="@+id/nav_import"
        android:icon="@drawable/ic_menu_manage"
        android:scrollHorizontally="false"
        android:ellipsize="none"
        android:title="@string/nav_option_import"
        android:visible="true" />
    <item
        android:id="@+id/nav_export"
        android:icon="@drawable/ic_menu_send"
        android:scrollHorizontally="false"
        android:ellipsize="none"
        android:title="@string/nav_option_export" />
    <item
        android:id="@+id/nav_manage"
        android:icon="@drawable/ic_menu_manage"
        android:title="Tools"
        android:visible="false" />
</group>

and the 2 strings that are not fully displayed以及未完全显示的 2 个字符串

<string name="nav_option_import">Besucherliste importieren</string>
<string name="nav_option_export">Besucherliste exportieren</string>

手机垂直时无法完全显示

水平时是否完全显示

if I am trying to ad a "\\n" in the string it doesn't work as well, furthermore I would like the text to wrap automatically如果我试图在字符串中添加一个 "\\n" 它也不起作用,而且我希望文本自动换行

I don't think there's an appropriate property to do so, however you can use android:titleCondensed property to display a shorter title when there's not enough space to display the whole title string.我认为没有合适的属性可以这样做,但是当没有足够的空间来显示整个标题字符串时,您可以使用android:titleCondensed属性来显示较短的标题。 Reference here参考这里

在此处输入图片说明 在此处输入图片说明<com.google.android.material.navigation.NavigationView android:layout_width="match_parent"使用此匹配父项

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

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