Umer Farooq
Umer Farooq

Reputation: 7486

Home Icon is not showing next to Hamburger icon in ActionBar

I am using AppCompat library for DrawerLayout. However the action bar is not showing the launcher icon next to hamburger menu icon. I have tried several ways to resolve this issue but none of them worked. Anybody has a clue how to resolve it?

I want to show an image just like here Google+ icon is visible next to hamburger icon.

enter image description here

Best Regards

Upvotes: 1

Views: 2406

Answers (1)

Umer Farooq
Umer Farooq

Reputation: 7486

The reason appIcon/launcher icon is not appearing in the actionBar is because of the new design guidelines of Material Design (Thanks to CommonsWare for telling). However I have used a much simpler & easier solution - Custom ActionBar.

Steps:

  1. Create an XML file which follows your design pattern for Action Bar
  2. In Activity:

    LayoutInflater inflater = LayoutInflater.from(this);
    inflater.inflate(R.layout.custom_action_bar, null);
    
    getSupportActionBar().setHomeEnabled(true); // for burger icon
    getSupportActionBar().setDisplayHomeAsUpEnabled(true); // burger icon related
    getSupportActionBar().setDisplayShowCustomEnabled(true); // CRUCIAL - for displaying your custom actionbar
    
    getSupportActionBar().setDisplayShowTitleEnabled(true); // false for hiding the title from actoinBar
    

Hopefully this will save some ones time.

Upvotes: 2

Related Questions