简体   繁体   中英

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:

<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

<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

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. Reference here

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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