2

I have set the homeAsUpIndicator to

<item name="homeAsUpIndicator">@drawable/ic_menu_icon</item>

globally in a stylesheet. Every Activity has the same icon now.

How can I change the icon in the ActionBar to be the left arrow (<-) again for one activity despite having it set globally in the stylesheet?

I tried to access android.R.drawable.ic_menu_back but I cannot access it (it seems it is private):

getSupportActionBar().setHomeButtonEnabled(false); // does not work
getSupportActionBar().setDisplayShowHomeEnabled(false); // does not work
// does not compile: getSupportActionBar().setHomeAsUpIndicator(android.R.drawable.ic_menu_back);
Jay Rathod
  • 11,131
  • 6
  • 34
  • 58
  • use getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); – H Raval Mar 23 '16 at 12:02
  • 3
    The name of the left arrow icon included with appcompat-v7 is `abc_ic_ab_back_mtrl_am_alpha` not `ic_menu_back`. As in `R.drawable.abc_ic_ab_back_mtrl_am_alpha` without the `android:` prefix. – Eugen Pechanec Mar 23 '16 at 12:09
  • That's perfect Eugen. Thanks a lot! – implicit_knowledge Mar 23 '16 at 12:29
  • It was probably updated some time ago, because I've found it under `R.drawable.abc_ic_ab_back_material` – Bernd Kampl Nov 13 '17 at 15:18
  • Possible duplicate of [Display Back Arrow on Toolbar](https://stackoverflow.com/questions/26651602/display-back-arrow-on-toolbar) – Borzh Mar 04 '19 at 22:46

1 Answers1

2

You can download this icon from the design google web page here it name is ic_arrow_back_white drop it into your drawable folder and then you would be able to acces it.

getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_back_24dp);
aiqency
  • 1,015
  • 1
  • 8
  • 22