nixfuerdiecharts
nixfuerdiecharts

Reputation: 383

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>

Doesn't display fully when phone is vertical

Does display fully when it is horizontal

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

Upvotes: 5

Views: 1782

Answers (3)

Sergey Stasishin
Sergey Stasishin

Reputation: 309

<com.google.android.material.navigation.NavigationView
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:maxWidth="350dp"

Try to use android:maxWidth attribute. It defaults to 280dp. You can overwrite it to achive a desired width of the drawer.

Upvotes: 1

naveeen
naveeen

Reputation: 21

enter image description here enter image description here

<com.google.android.material.navigation.NavigationView
              android:layout_width="match_parent"

use this match parent

Upvotes: 2

Nicola Gallazzi
Nicola Gallazzi

Reputation: 8705

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

Upvotes: 1

Related Questions