1

Just started to learn basic Android programming. Trying to create a navigation drawer (which has been done), but my drawer icon is out of place and I want to remove the little green android icon at the top left. Don't wanna just delete the image from the drawable folder in case I decide to add one after all. How can I hide/remove this icon through the xml/java files, and how would I shift the drawer icon into place? enter image description here

user3763216
  • 489
  • 2
  • 9
  • 28
  • Set your actionbar icon to null. Something like `actionBar.setIcon(null);` – Phantômaxx Jun 04 '15 at 12:00
  • Take a look at this answer: http://stackoverflow.com/questions/9252354/how-to-customize-the-back-button-on-actionbar/9265774#9265774 – Sandro Machado Jun 04 '15 at 12:01
  • Check this links: http://stackoverflow.com/questions/15715309/application-launcher-icon-being-displayed-on-action-bar-of-an-activity http://stackoverflow.com/questions/5720715/remove-application-icon-and-title-from-honeycomb-action-bar http://stackoverflow.com/questions/11430712/hide-application-launcher-icon-in-title-bar-when-activity-starts-in-android – Mu Sa Jun 04 '15 at 12:01

1 Answers1

3

If you want to hide the icon simply set a transparent color instead like this:

getActionBar().setIcon(android.R.color.transparent);

And if you want to replace the icon:

getActionBar().setIcon(R.drawable.my_icon);
jlopez
  • 6,287
  • 2
  • 51
  • 90
  • It works! But my drawer icon is still stuck too much to the left :-( – user3763216 Jun 04 '15 at 12:28
  • 1
    Glad to help :) If you need to center your icon, you should set your customView to the action bar like `getActionBar()setCustomView` checkout this answer:http://stackoverflow.com/a/12388200/1484779 – jlopez Jun 04 '15 at 12:37
  • 1
    If you only need a small margin you can do a little trick, Apply a small padding-left to your icon for extra space – jlopez Jun 04 '15 at 12:40