show icon in actionbar/toolbar with AppCompat-v7 21

ligi picture ligi · Oct 18, 2014 · Viewed 159.5k times · Source

I tried these - but still do not see the icon like before:

getSupportActionBar().setLogo(R.drawable.ic_launcher);
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);

It seems to work when I use custom toolbar - but that would force me to touch all layouts - is there a better way to do so?

Answer

nadavfima picture nadavfima · Oct 19, 2014
getSupportActionBar().setDisplayShowHomeEnabled(true);

along with

getSupportActionBar().setIcon(R.drawable.ic_launcher);