This is post for changing the Hamburger Icon in Android Programmatic ways .So lets Start with brief Introduction of Hamburger Icon in Android.
Hamburger icon:
The hamburger button is a button in a graphical user interface carrying an icon consisting of three parallel horizontal lines (displayed as ☰). It is often placed in the top left or top right of a user interface and is so called for its resemblance to a hamburger icon.
it will look like this in Android Apps:
Lets start with Changing the Hamburger Icon Programmatic Ways.There are some steps to follow:
Step 1:
Setup the drawer toggle
mDrawerToggle = ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close);
Step 2:
Set the DrawerIndicatorEnabled to false
mDrawerToggle.setDrawerIndicatorEnabled(false);
Step 3:
Set the listener to the drawer Toggle because by above setup your hamburger button click
mDrawerToggle.setToolbarNavigationClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mDrawerLayout.openDrawer(GravityCompat.START);
}
});
Step 4:
Finally set the icon
mDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_hamburg);
Thats All, In This way you can change the default Hamburger Icon in Android.
Comments
Post a Comment