Change Icon Of Navigation Drawer

change navigation drawer icon in toolbar android
change navigation bar icon android
set navigation drawer icon
how to change navigation drawer hamburger icon color in android
custom navigation drawer in android
change navigation drawer icon color''>@android
how to change navigation drawer icon size in android
navigation drawer icon color not showing

I am having trouble with changing my navigation drawer icon to a custom one. I've currently had to implement the standard drawer icon which has 3 horizontal lines on top, but now I want to replace this with my custom drawer icon.

This is how my mDrawerToggle is at the moment:

mDrawerToggle=new ActionBarDrawerToggle(this,
    mDrawerLayout,
    R.drawable.app_icon,
    R.string.drawer_open) {
        // My code
    };

Here is the sample code taken from Creating a Navigation Drawer

Activity.class

public class MainActivity extends Activity {
    private DrawerLayout mDrawerLayout;
    private ActionBarDrawerToggle mDrawerToggle;
    ...

    public void onCreate(Bundle savedInstanceState) {
        ...

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerToggle = new ActionBarDrawerToggle(
                this,                  /* host Activity */
                mDrawerLayout,         /* DrawerLayout object */
                R.drawable.ic_drawer,  /* nav drawer icon to replace 'Up' caret */
                R.string.drawer_open,  /* "open drawer" description */
                R.string.drawer_close  /* "close drawer" description */
                ) {

            /** Called when a drawer has settled in a completely closed state. */
            public void onDrawerClosed(View view) {
                super.onDrawerClosed(view);
                getActionBar().setTitle(mTitle);
            }

            /** Called when a drawer has settled in a completely open state. */
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                getActionBar().setTitle(mDrawerTitle);
            }
        };

        // Set the drawer toggle as the DrawerListener
        mDrawerLayout.setDrawerListener(mDrawerToggle);

        getActionBar().setDisplayHomeAsUpEnabled(true);
        getActionBar().setHomeButtonEnabled(true);
    }

    @Override
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        // Sync the toggle state after onRestoreInstanceState has occurred.
        mDrawerToggle.syncState();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        mDrawerToggle.onConfigurationChanged(newConfig);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Pass the event to ActionBarDrawerToggle, if it returns
        // true, then it has handled the app icon touch event
        if (mDrawerToggle.onOptionsItemSelected(item)) {
          return true;
        }
        // Handle your other action bar items...

        return super.onOptionsItemSelected(item);
    }

    ...
}

Changing Navigation Drawer Icon (Burger Button) on Actionbar , How to Changing Navigation Drawer Icon (Burger button) on Actionbar Download Source Code Duration: 4:55 Posted: Dec 2, 2018 In this android programming source code example, we are going to change the color of navigation drawer indicator icon in android. You can copy and adopt this source code example to your android project without reinventing the wheel. Below is a step by step source code to change the color of navigation drawer indicator icon in android.

Use below code,it's working for V7 ActionBarDrawerToggle

mDrawerToggle.setDrawerIndicatorEnabled(false);

mDrawerToggle.setHomeAsUpIndicator(R.drawable.your_custom_icon);
 mDrawerToggle.setToolbarNavigationClickListener(new View.OnClickListener() {
@Override
 public void onClick(View v) {
     if (mDrawerLayout.isDrawerVisible(GravityCompat.START)) {
          mDrawerLayout.closeDrawer(GravityCompat.START);
     } else {
         mDrawerLayout.openDrawer(GravityCompat.START);
    }
}
});

How to customize navigation drawer, This video shows how to design/ customize ( changing icons, text, icon color, text color Duration: 13:36 Posted: Mar 7, 2018 Navigation Drawer hamburger icon change and colour change If you are using Appbar you can add leading Icon to replace the hamburger Icon. You can set IconButton for that and setting the colour will also change the Icon colour of that button. But when you add a custom button it will lose the drawer open capability.

This is main activity

final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);


        toggle.setDrawerIndicatorEnabled(false);

        toggle.setToolbarNavigationClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                drawer.openDrawer(GravityCompat.START);
            }
        });

        toggle.setHomeAsUpIndicator(R.drawable.menuicon);

Changing Navigation Drawer Icon Colors: Android Studio, Learn how to create a Navigation Drawer Activity in Android Studio in the Simplest way and how Duration: 2:19 Posted: Apr 6, 2019 Navigation Drawer hamburger icon change and colour change. If you are using Appbar you can add leading Icon to replace the hamburger Icon. You can set IconButton for that and setting the colour

You could use this format for your mDrawerToggle:

mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
    R.drawable.CUSTOM_ICON, // Navigation menu toggle icon
    R.string.DRAWER_OPEN, // Navigation drawer open description
    R.string.DRAWER_CLOSE // Navigation drawer close description
    )

Change your drawable and make sure it is the same name as the one in the code.

Android Navigation Drawer, png as the icon. To use any such a third party png file, you need to import it in the drawable folder. Step 12: Change the content� The visibility of a standard navigation drawer depends on screen size, app layout, and frequency of use. Dismissible standard drawers can be used for layouts that prioritize content (such as a photo gallery) or for apps where users are unlikely to switch destinations often. They should use a visible navigation menu icon to open and close the

This is the main layout file

<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" >

    <!-- Framelayout to display Fragments -->

    <FrameLayout
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- Listview to display slider menu -->

    <ListView
        android:id="@+id/list_slidermenu"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/white"
        android:choiceMode="singleChoice"
        android:divider="@color/black"
        android:dividerHeight="1dp" />

</android.support.v4.widget.DrawerLayout>

This is the main Activity

DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
                R.drawable.menuicon, // nav menu toggle icon
                R.string.app_name, // nav drawer open - description for
                                    // accessibility
                R.string.app_name // nav drawer close - description for
                                    // accessibility
        ) {
            public void onDrawerClosed(View view) {
                // getActionBar().setTitle(mTitle);
                // calling onPrepareOptionsMenu() to show action bar icons
                invalidateOptionsMenu();
            }

            public void onDrawerOpened(View drawerView) {
                // getActionBar().setTitle(mDrawerTitle);
                // calling onPrepareOptionsMenu() to hide action bar icons
                invalidateOptionsMenu();
            }
        };
        mDrawerLayout.setDrawerListener(mDrawerToggle);

finally at R.drawable.menuicon(you can give your image id) it will work.

Change Navigation Menu Icon, In this article, we will look how we can change navigation menu icon in You just need to add this line after you have set drawer toggle� The navigation drawer is a panel that displays the app’s main navigation options on the left edge of the screen. It is hidden most of the time, but is revealed when the user swipes a finger from the left edge of the screen or, while at the top level of the app, the user touches the app icon in the action bar. This tutorial guides you on how to create a navigable drawer application.

Fragment Navigation Drawer, Read the material design style navigation drawer document for specs on styling an Up icon (<-), we will replace it with hamburger later getSupportActionBar(). The navigation drawer is a UI panel that shows your app's main navigation menu. It is hidden when not in use, but appears when the user swipes a finger from the left edge of the screen or when at the top level of the app, the user touches the drawer icon in the app bar.

How to change the Navigation Drawer icon � Issue #1288 � mikepenz , Hi! How can I change the default navigation (hamburger) icon? I have tried the following but it does not change getSupportActionBar(). Drawer navigation Common pattern in navigation is to use drawer from left (sometimes right) side for navigating between screens. Before continuing, first install @react-navigation/drawer :

How to change Navigation Drawer icon color in android, In this android programming source code example, we are going to change the color of navigation drawer indicator icon in android. You can copy and adopt this. In this Google flutter code example we are going to learn how to change the Drawer hamburger icon color in Flutter. You can copy and adopt this source code example to your Flutter project without reinventing the wheel.

Comments
  • Is the above how you are going about it currently?
  • yeh right @FarbodSalamat-Zadeh
  • try set homeAsUpIndicator() with icon.
  • @Harry i had tried that too...mDrawerToggle.setHomeAsUpIndicator(R.drawable.app_icon);
  • Yar @Tarun jain i had done same thing ...what is my problem check that... i know constructor of mdrawertoogle
  • @Tufan Did u added the following code.. @Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); mDrawerToggle.onConfigurationChanged(newConfig); }
  • i had override both the method ....look at my pics my icon is displayed but when i wanna change ..it dosent change
  • if i add R.String.drawer_close then it gives me error change construcitr or change ic_drawer to toolbar..any soln
  • Can u check the import whether it is using V4 support library or not
  • Suggestion: You can use the Drawable resource id for setting an image file as a Navigation Drawer Icon. Example: mDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_navigation_home_icon); Hence, no need of using the below code: Drawable drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.your_custom_icon, getActivity().getTheme());
  • This was the best option for me. Setting the icon explicitly, rather than letting Android figure out whether to show a menu icon or back icon, is a lot more consistent for my app.
  • Why doesn't the icon auto-resize. When I use a 512*512 icon, It takes up the entire ActionBar.