title: Background image and image view in Navigation Drawer
body: <p>I am trying out a navigation drawer design similar to play store App: I have got the menu part things working fine but I would like to add the profile image and user id in the top of menu like image below. I am not sure how to achieve this part:</p>
  
  <p><img src="https://i.stack.imgur.com/76df5.png" alt="enter image description here"></p>
  
  <p>I have tried the following code and added it in xml which has the list of items to be shown.</p>
  
  <pre><code>&lt;LinearLayout
      android:id="@+id/LinearLayoutFrom1"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:gravity="left|center"
      android:background="@drawable/bg"
      android:orientation="horizontal" &gt;
  
      &lt;ImageView
          android:id="@+id/clear1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/profilepic" /&gt;
  
      &lt;TextView
          android:id="@+id/textViewName"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="center"
          android:text="UserID"
          android:textColor="#FFFFFF"
          android:textSize="15sp"
          android:textStyle="bold" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>but this just appends the background and text for each listitem. </p>
  
  <p>How do I achieve the above design?</p>
  
  <p><strong>UPDATE 1:</strong></p>
  
  <p>I tried the following in the XML:</p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/drawer_layout"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;FrameLayout
      android:id="@+id/framelayoutid"
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  
  
  &lt;LinearLayout
      android:id="@+id/LinearLayoutFrom1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@drawable/bg"
      android:orientation="vertical" &gt;
  
      &lt;LinearLayout
          android:id="@+id/LinearLayoutFrom2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="horizontal"
          android:layout_weight=".20" &gt;
  
          &lt;ImageView
              android:id="@+id/clear1"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:src="@drawable/profilepic" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/LinearLayoutFrom3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_weight=".80"
          android:orientation="horizontal" &gt;
  
          &lt;TextView
              android:id="@+id/textViewName"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:text="UserID"
              android:textColor="#FFFFFF"
              android:textSize="15sp"
              android:textStyle="bold" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;ListView
          android:id="@+id/left_panel"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:background="@color/list"
          android:choiceMode="singleChoice"
          android:divider="@color/divider"
          android:dividerHeight="1dp"
          android:listSelector="@drawable/selector" /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>I get the following error:</p>
  
  <p><a href="http://txs.io/4bpb" rel="nofollow noreferrer">http://txs.io/4bpb</a></p>
  
  <p><strong>Update 2:</strong></p>
  
  <p>I managed to add header to list by doing the following:</p>
  
  <pre><code>    mDrawerList = (ListView) findViewById(R.id.left_menu);
  
      View header = getLayoutInflater().inflate(R.layout.headerlayoutfordrawer, null); 
      mDrawerList.addHeaderView(header);
  
      navDrawerItems = new ArrayList&lt;NavDrawerItem&gt;();
  
      navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1)));
      navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1),true, "2"));
      navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1)));
      navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1)));
      navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));
      navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons.getResourceId(5, -1)));
      navMenuIcons.recycle();
  
      mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
  
      adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems);
      mDrawerList.setAdapter(adapter);
  </code></pre>
  
  <p>But the problem is that the header is also being counted in arraylist in DrawerItems and hence I get array outofboundexception</p>
  
  <pre><code>  07-22 11:18:01.433: E/AndroidRuntime(14229): FATAL EXCEPTION: main
    07-22 11:18:01.433: E/AndroidRuntime(14229): java.lang.ArrayIndexOutOfBoundsException: length=6; index=7
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at com.jlk.trip.maps.displayView(maps.java:192)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at com.jlk.trip.maps.access$0(maps.java:159)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at com.jlk.trip.maps.maps$SlideMenuClickListener.onItemClick(maps.java:122)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at android.widget.AdapterView.performItemClick(AdapterView.java:298)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:2788)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at android.widget.AbsListView$1.run(AbsListView.java:3463)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at android.os.Handler.handleCallback(Handler.java:730)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at android.os.Handler.dispatchMessage(Handler.java:92)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at android.os.Looper.loop(Looper.java:137)  
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at android.app.ActivityThread.main(ActivityThread.java:5103)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at java.lang.reflect.Method.invokeNative(Native Method)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at java.lang.reflect.Method.invoke(Method.java:525)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    07-22 11:18:01.433: E/AndroidRuntime(14229):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>