Prinx Ghimirey
Prinx Ghimirey

Reputation: 11

Add Logo (Icon) and app name on the ActionBar?

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

Upvotes: 1

Views: 512

Answers (2)

Yasin Kaçmaz
Yasin Kaçmaz

Reputation: 6663

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

Upvotes: 1

OneCricketeer
OneCricketeer

Reputation: 191681

Have you tried setTitle() and setNavigationIcon()?

Toolbar toolbar=(Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("Title");
toolbar.setNavigationIcon(R.drawable.some_icon);

Upvotes: 2

Related Questions