Skip to content Skip to sidebar Skip to footer

Background Image And Image View In Navigation Drawer

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

Solution 1:

UPDATE:

Take a look at this project for everything related with the drawer. https://github.com/Sottti/MaterialDesignNavDrawer

OLD ANSWER:

Take a look at my xml here: https://github.com/Sottti/BuyIt/blob/master/BuyIt/src/main/res/layout/activity_main.xml

Pay attention at where it says "YOUR DRAWER".

The Navigation Drawer is the second child in android.support.v4.widget.DrawerLayout.

The second child is a LinearLayout containing a RelativeLayout and a ListView.

The ListView is the Drawer list view it self.

The Relative layout is the place where the image header is located.

Try that, it's working for me.

Luck!!

Solution 2:

You can find how Google handle this issue in navdrawer_content layout of Google IO's Android app. Short answer: they don't use ListView.

Solution 3:

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);
        }

Post a Comment for "Background Image And Image View In Navigation Drawer"