Search code examples
androidandroid-actionbarandroid-homebutton

Custom image instead of logo in ActionBar


How to set logo icon of an ActionBar to be a custom image? Similar as how it works on Whatsapp? I have tried to implement but its looking like this..enter image description here

How to remove the space?

I used like this

getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setIcon(R.drawable.dummy_user_profile_pic);

and in manifest

<application
        android:logo="@drawable/dummy_user_profile_pic"

What im doing wrong? please guide me. Thanks a lot


Solution

  • I referred this link and i can able to achieve it. But the space between home and image is default space comes from App-compat Support Library Toolbar Where as in Whatsapp there is no space. I think they didn't use Support Library Toolbar. You can see the default space when you provide the tittle to actionbar.