1

How can I add app logo as well as app name?
I tried, but either logo appears or app name, not both.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

2 Answers2

2

Have you tried setTitle() and setNavigationIcon()?

Toolbar toolbar=(Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("Title");
toolbar.setNavigationIcon(R.drawable.some_icon);
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
1

Just simple way :

Toolbar toolbar=(Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if(getSupportActionBar()!=null){
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(drawerArrowDrawable);
    getSupportActionBar().setIcon(R.drawable.ic_label_black_48dp);
}

You will see a screen like that :

enter image description here

Yasin Kaçmaz
  • 6,573
  • 5
  • 40
  • 58
  • You don't need `getSupportActionBar`, do you? You already have `toolbar` – OneCricketeer Aug 19 '16 at 17:32
  • @cricket_007 `getSupportActionBar` returns an `ActionBar` and it has these methods. `Toolbar` don't have these methods. Maybe we can cast `Toolbar` to `ActionBar` but never tried like that, let me try. @Edit : I tried to cast `Toolbar` to `ActionBar` but not allowed. – Yasin Kaçmaz Aug 19 '16 at 17:34