6

I'm using SlidingMenu libs (https://github.com/jfeinstein10/SlidingMenu) to get the Navigation Drawer of my app. It feels and looks amazing but I have a issue: I want to use a big picture with a textview on top of is to display the user photo and name (check the image).

How do I achieve this look? The XML menu file won't let me add a ImageView or TextView, just items and inside of those there are very limited options of customization.

Check the image attached for a better look of what I have in mind.

Thanks in advance.

Nav Drawer image

Ahmad
  • 69,608
  • 17
  • 111
  • 137
guilhermexot
  • 277
  • 4
  • 11

2 Answers2

4

First of all this is not the SlidingMenu you are referring to. The image is showing the official DrawerLayout.

As far as your actual question goes:

The menu only consists of a ListView, so you just have to customize your ListView to display an image for the first row. You could either create a custom adapter for that or set the image via
addHeaderView (View v, Object data, boolean isSelectable).

Ahmad
  • 69,608
  • 17
  • 111
  • 137
  • The SlidisingMenu libs are implemented in the project, this is the mockup of where I want to get with it. So, if I want to add an image there I need to do it via java? Is it possible to do it with the xml too? THanks – guilhermexot Aug 24 '13 at 17:43
  • 1
    Yeah you have to do it programmatically. – Ahmad Aug 24 '13 at 17:44
0

Use the addHeaderView() method provided by ListView.
Note: this will cause the ArrayAdapter to interpret the image as the first item in your list. To deal with this, use the option in addHeaderView to disable clicking, and move all the elements in your array up by 1 (essentially creating a dummy value at the 0th element).

When your navigation drawer is first called, you may need to add a snippet like the following:

if (savedInstanceState == null) {
    selectItem(1);
}
benka
  • 4,732
  • 35
  • 47
  • 58
zafirk
  • 79
  • 1
  • 1