How to add custom views in the new NavigationView

The new support library 23.1 allows using a custom view for the items in Navigation View using app:actionLayout or using MenuItemCompat.setActionView(). Here’s how I managed to display a SwitchCompat menu_nav.xml <?xml version=”1.0″ encoding=”utf-8″?> <menu xmlns:android=”http://schemas.android.com/apk/res/android”> <group android:id=”@+id/first” android:checkableBehavior=”single”> <item android:id=”@+id/navi_item_1″ android:icon=”@drawable/ic_feed_grey_500_24dp” android:title=”Feed” /> <item android:id=”@+id/navi_item_2″ android:icon=”@drawable/ic_explore_grey_500_24dp” android:title=”Explore” /> <item android:id=”@+id/navi_item_4″ android:icon=”@drawable/ic_settings_grey_500_24dp” android:title=”Settings” /> </group> <group … Read more

How can I change separator color in NavigationView?

just apply following line on style.xml <item name=”android:listDivider”>your_color</item> The below is just information for your knowledge … If you have seen design support library .. they are using following layout for NavigationView seprator.. <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”wrap_content”> <View android:layout_width=”match_parent” android:layout_height=”1dp” android:background=”?android:attr/listDivider”/> </FrameLayout> here, you can see android:background=”?android:attr/listDivider” .. So enjoy … and here is my … Read more

NavigationView and custom Layout

Here’s how I solved it, and worked perfectly: <android.support.design.widget.NavigationView android:id=”@+id/navigation” android:layout_width=”wrap_content” android:layout_height=”match_parent” android:layout_gravity=”start” android:fitsSystemWindows=”true”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical”> <include layout=”@layout/nav_header” /> <ListView android:id=”@+id/lst_menu_items” android:layout_width=”match_parent” android:layout_height=”0dp” android:layout_weight=”1″ /> </LinearLayout> </android.support.design.widget.NavigationView>