0

I have a NavigationView that has an app:headerLayout and an app:menu that has three groups of items. One of this groups is made for social media:

    <menu>
        <item
            android:id="@+id/nav_facebook"
            android:icon="@drawable/ic_facebook"
            android:title="@string/nav_drawer_facebook" />
        <item
            android:id="@+id/nav_twitter"
            android:icon="@drawable/ic_twitter"
            android:title="@string/nav_drawer_twitter" />
        <item
            android:id="@+id/nav_instagram"
            android:icon="@drawable/ic_instagram"
            android:title="@string/nav_drawer_instagram" />
        <item
            android:id="@+id/nav_google_plus"
            android:icon="@drawable/ic_google"
            android:title="@string/nav_drawer_googleplus" />
        <item
            android:id="@+id/nav_share"
            android:icon="@drawable/ic_menu_share"
            android:title="@string/nav_drawer_share" />
    </menu>

So my question is if there is any way to make the orientation of this menu horizontal:

At this moment it looks like this:

enter image description here

But I would like it to look like this:

enter image description here

I would like to show the icons next to the other to safe some space. I know I could achieve this doing a custom layout but I would like to know if there is a way to do this with the app:menu.

Any help would be appreciated. Thanxs in advance.

QuinDa
  • 918
  • 1
  • 12
  • 19

3 Answers3

1

Just add

app:actionLayout="@layout/action_layout"

into an item, where action_layout is the layout that you want to show in horizontal orientation here is an example:

<item
   android:id="@+id/nav_manage"
   android:title="layout"
   app:actionLayout="@layout/action_layout" /> 
0

Just put this line

app:showAsAction="always"

Uddhav P. Gautam
  • 7,362
  • 3
  • 47
  • 64
0

I do this but everytime I am making mistake I am writing this...

<item
android:id="@+id/nav_item"
android:title="@string/title"
android:actionlayout="@layout/mylayout_nav_item" />

But Instead Write This...

<item
android:id="@+id/nav_item"
android:title="@string/title"
app:actionlayout="@layout/mylayout_nav_item" />

It is not showing

  • app:actionLayout

but you have to type it... It will not show error when you give layout and all