How to Add a Toolbar – Android Studio Tutorial



In this video we will learn, how we can replace the default action bar with a toolbar, which is more customizable and more flexible. We will define it in a seperate xml file so we can include it into different other layouts. We will also change it’s theme so the text and menu icon are white instead of black.

Source code:

____________________
Subscribe to my channel:

Want more Android tutorials? Check my playlist section:

Follow me on social media:

Facebook:

Instagram:

Twitter:

Blog:

25 Replies to “How to Add a Toolbar – Android Studio Tutorial”

  1. Duc Bui Huynh

    I met a problem that when I add theme "@style/ThemeOverlay.AppCompat.Dark.ActionBar" to display a option icon like but just title was displayed, no see option icon

  2. Der_Googler

    Help please?!

    app/src/main/res/values-v21/styles.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'.

  3. FR

    If anyone wasn't able to get this to work make sure you add the onCreateOptionsMenu in the main activity and also create a new directory called menu with a new resource file and copy in the code listed in his example_menu.xml file

  4. Ravi

    I think you should put the toolbar inside appBar layout. By default it will enable elevation. Because you can't add elevation yourself below api 21, it is deprecated. Rest of this the tutoria is quite good.

  5. Samuel Custer

    Excellent tutorial, love the proactive tips to prevent bad habits (reusable layout example). I've see those kinds of mistakes all too much (even in large corporate environments).

  6. یوسف زین ساز

    hello my friends , i need help first i create toolbar and second create options menu but when i long press three dots we have tooltip and tooltiptext is "more options" but i dont need this string and i need to change it can you help me set tooltip for options menu ? thank you .

Leave a Reply

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