Adding a large image to the navigation box (SlidingMenu libs) - How to do this?

I am using SlidingMenu libs ( https://github.com/jfeinstein10/SlidingMenu ) to get the navigation box of my application. It feels and looks amazing, but I have a problem: I want to use a large picture with a text label to display the user's photo and name (check the image).

How can I achieve this? The XML menu file does not allow you to add ImageView or TextView, only elements and there are very limited customization options inside them.

Check out the image attached for a better view of what I mean.

Thanks in advance.

Nav Drawer image

+6
source share
2 answers

First of all, this is not the SlidingMenu that you are talking about. The image displays the official DrawerLayout .

Regarding your current question:

The menu consists only of ListView , so you need to configure ListView to display the image for the first row. You can create a custom adapter for this or set the image using addHeaderView (View v, Object data, boolean isSelectable) .

+4
source

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

When you first call up the navigation box, you may need to add a fragment of the following form:

 if (savedInstanceState == null) { selectItem(1); } 
0
source

Source: https://habr.com/ru/post/952428/


All Articles