0

I have a navigation drawer, and next to the universal "this button opens up the slide menu" button (the one that is three horizontal lines) whatever I set the application icon to appears next to it. I can't simply replace the image with a blank one, because then there's no app icon when you try to open up the application. Is there a way to remove this from the navigation drawer without affecting the app icon? I've looked in the drawer_layout, in the code to set it up . . . I can't seem to find where this icon is getting added to the titlebar.

Here's my code for creating the menu:

private void setupDrawer(){
    mTitle = mDrawerTitle = getTitle();
    mForumTitles = getResources().getStringArray(R.array.main_menu_array); 

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);


    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener
    mDrawerList.setAdapter(new ArrayAdapter<String>(this,
            R.layout.drawer_list_item, mForumTitles));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);


    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(
            this,                  /* host Activity */
            mDrawerLayout,         /* DrawerLayout object */
            R.drawable.ic_drawer,  /* nav drawer image to replace 'Up' caret */

            R.string.drawer_open,  /* "open drawer" description for accessibility */
            R.string.drawer_close  /* "close drawer" description for accessibility */
            ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle("Menu");
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            //getActionBar().setTitle(mDrawerTitle);

            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
}

Any ideas? I'll post any other portions of code or xml files necessary.

Marcel Marino
  • 962
  • 3
  • 17
  • 34

3 Answers3

2

You can hide the icon from actionbar in you style definition. Check this answer for how to do it.

Community
  • 1
  • 1
Lamorak
  • 10,957
  • 9
  • 43
  • 57
0

What you should do is add the logo as your home as up Indicator instead of the 3 bars:

<item name="displayOptions">showHome|showTitle|homeAsUp</item>      
<item name="homeAsUpIndicator">R.drawable.icon</item>

to your Style which its parent must be of Theme.AppCompat

kandroidj
  • 13,784
  • 5
  • 64
  • 76
0
actionBarDrawerToggle.setDrawerIndicatorEnabled(false);

In my case, the navigation button was invisible but still occupying the place, so I managed to remove it completely from the toolbar by the above code. Just in case, for those who are customizing their Toolbar and DrawerLayout.

Merve Gencer
  • 87
  • 1
  • 5