title: How can I add a custom item to a NavigationView with a menu layout?
body: <p>I've been experimenting with simplifying some navigation drawer code by making use of the new <a href="https://developer.android.com/reference/android/support/design/widget/NavigationView.html" rel="noreferrer"><code>NavigationView</code></a> class in the Android design support library. It works great if you just want icons on the left, and text on the right like in the example in the documentation, but what if I want to add a single custom view to the layout which has an <code>android.support.v7.widget.SwitchCompat</code> like in the Google Play Movies app (see screenshot below)?</p>
  
  <p><img src="https://i.stack.imgur.com/rBM4Hl.png" alt="Google Play Movies"></p>
  
  <p>I've tried using the <code>actionLayout</code> attribute to specify a custom layout file like in the example code below, however that attribute appeared to be ignored as it didn't work.</p>
  
  <p><code>res/menu/navigation_drawer.xml</code></p>
  
  <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;group android:id="@+id/group1"
              android:checkableBehavior="single"&gt;
          &lt;item
              android:id="@+id/nav_screen1"
              android:icon="@drawable/ic_list_black_24dp"
              android:title="Screen 1" /&gt;
          &lt;item
              android:id="@+id/nav_screen2"
              android:icon="@drawable/ic_search_black_24dp"
              android:title="Screen2"/&gt;
      &lt;/group&gt;
      &lt;group  android:id="@+id/group2"&gt;
          &lt;item
              android:id="@+id/nav_custom"
              android:icon="@drawable/custom_icon_24dp"
              app:actionLayout="@layout/nav_drawer_switch"
              android:title="Custom item with switch"/&gt;
          &lt;item
              android:id="@+id/nav_settings"
              android:icon="@drawable/ic_settings_black_24dp"
              android:title="Settings"/&gt;
      &lt;/group&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p><code>res/layout/nav_drawer_switch.xml</code></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="horizontal" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
      &lt;android.support.v7.widget.SwitchCompat
          android:layout_width="fill_parent"
          android:layout_height="match_parent"
          android:text="Custom item with switch"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>How can I get this to work? Ideally I'd like to add the custom view while still making use of my Menu layout, but if that's not possible without using a crude hack (like tapping into an existing layout generated by the support library) then I'd like to know the solution with the least amount of code, and which still makes it worth transitioning to <code>NavigationView</code>.</p>