Search code examples
androidnavigation-drawerdrawerlayoutdrawertoggle

how to remove icon for drawer fragment


I have used actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setHomeButtonEnabled(false); to remove the drawer icon. It worked but it seems the icon still occupies the space as before. Also, there remains a small transparent button that can be used to open the drawer. Can I remove the icon "completely"? Or what's the exact width the icon will occupy so that I can add same margin at right.


Solution

  • First set setDrawerIndicatorEnabled(false), this will revert to the android.R.attr.homeAsUpIndicator drawable provided from the theme. Then calling actionBar.setDisplayHomeAsUpEnabled(false) and actionBar.setHomeButtonEnabled(false); will hide the indicator.