How to add a navigation view in the new android support library -


i'm doing in layout :

<android.support.v4.widget.drawerlayout         xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:app="http://schemas.android.com/apk/res-auto"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:fitssystemwindows="true">      <!-- content layout -->      <android.support.design.widget.navigationview             android:layout_width="wrap_content"             android:layout_height="match_parent"             android:layout_gravity="start"             app:headerlayout="@layout/drawer_header"             app:menu="@menu/drawer"/> </android.support.v4.widget.drawerlayout> 

and in menu :

<item     android:id="@+id/navigation_subheader"     android:title="@string/navigation_subheader">     <menu>         <item             android:id="@+id/navigation_sub_item_1"             android:icon="@drawable/ic_android"             android:title="@string/navigation_sub_item_1"/>         <item             android:id="@+id/navigation_sub_item_2"             android:icon="@drawable/ic_android"             android:title="@string/navigation_sub_item_2"/>     </menu> </item> 

first problem if can't see elements of navigation drawer. second problem if want add header can see it.for header i'm puttin relative alyout have red background.

first problem if can't see elements of navigation drawer.

if understand correctly @ least see 1 item right? try use instead:

<group android:checkablebehavior="single">     <item         android:id="@+id/navigation_item_1"         android:checked="true"         android:icon="@drawable/ic_android"         android:title="@string/navigation_item_1"/>     <item         android:id="@+id/navigation_item_2"         android:icon="@drawable/ic_android"         android:title="@string/navigation_item_2"/> </group> 

see if works. navigation drawers begin navigation items (the group seen above) , below use sub header grouped items.

second problem if want add header can see it.for header i'm puttin relative alyout have red background.

you need set height header layout (or minheight). doesn't know how big needs be.

if want sample project can take @ sample project provided chris banes: https://github.com/chrisbanes/cheesesquare


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -