material design – How can I use an icon instead of a title in the Android Toolbar?-ThrowExceptions

Exception or error:

I’m using the Toolbar (instead of ActionBar) via AppCompat. I’d like to replace the Toolbar’s title (the app/actity name) with an icon, but I don’t see how.

My icon is just text using a non-standard font, so I guess it might be allowed in Material Design.

How to solve:

Use the following steps in your activity:

  1. Declare the Toolbar object:

    Toolbar toolbar = (Toolbar) findViewById(;
  2. Set the support actionbar:

  3. Remove title:

  4. Add your logo in drawable folder in:

  5. Add logo using this code:



Here is the answer to a very similar question:
Android Lollipop, add popup menu from title in toolbar

It comes down to using the Toolbar as a ViewGroup (LinearLayout is a ViewGroup too, for instance). The layout designer doesn’t currently support that, but you can add a child node in the XML.

Then you need to call this to remove the standard title text:

Leave a Reply

Your email address will not be published. Required fields are marked *