Questions tagged [android-toolbar]

A Toolbar is a widget based generalization of action bars for use within layouts.

The Toolbar was introduced in Android 5.0 Lollipop however it was also added to Added to appcompat-v7:21.0.0 for backwards compatibility. The widget consists of a navigation button, a title and subtitle, one or more custom views and an action menu. You should use Toolbar instead of Actionbar when you want to use the Actionbar features but you require more control over it's appearance, if you want multiple Actionbars, or if you want Actionbars that only take up part of the width of the screen.

For more information:

See also:

3018 questions
551
votes
25 answers

Display Back Arrow on Toolbar

I'm migrating from ActionBar to Toolbar in my application. But I don't know how to display and set click event on Back Arrow on Toolbar like I did on Actionbar. With ActionBar, I call mActionbar.setDisplayHomeAsUpEnabled(true). But there is no…
547
votes
23 answers

This Activity already has an action bar supplied by the window decor

Trying to move over my stuff to use Toolbar instead of action bar but I keep getting an error saying java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tyczj.weddingalbum/com.xxx.xxx.MainActivity}:…
389
votes
35 answers

Android toolbar center title and custom font

I'm trying to figure out the right way to use a custom font for the toolbar title, and center it in the toolbar (client requirement). At the moment, i'm using the good old ActionBar, and I was setting the title to empty value, and using…
205
votes
1 answer

What is the difference between Action Bar and newly introduced Toolbar?

After Google introduced Material Design, I have heard about a new widget class called Toolbar. What is the Toolbar, and what is the exact difference between ActionBar and ToolBar?
김준호
  • 14,557
  • 7
  • 39
  • 35
202
votes
10 answers

Android API 21 Toolbar Padding

How do I get rid of the extra padding in the new Toolbar with Android SDK API version 21 (the support library)? I am talking about the red arrows on this picture: Here is the code I am using:
James Cross
  • 7,659
  • 8
  • 21
  • 30
187
votes
4 answers
183
votes
7 answers

Toolbar and Contextual ActionBar with AppCompat-v7

I am working on using the newly added Toolbar that was introduced in Lollipop and the AppCompat-v7 library. I followed this guide on setting up the Toolbar I noticed that when you invoke something that will bring up the contextual ActionBar (such as…
ariets
  • 4,098
  • 4
  • 25
  • 34
180
votes
18 answers

Remove title in Toolbar in appcompat-v7

The documentation of Toolbar says If an app uses a logo image it should strongly consider omitting a title and subtitle. What is the proper way to remove the title?
timemanx
  • 4,838
  • 5
  • 31
  • 42
170
votes
18 answers

No shadow by default on Toolbar?

I'm updating my app with the new Toolbar from the support library v21. My problem is that the toolbar does not cast any shadow if I don't set the "elevation" attribute. Is that the normal behavior or I'm doing something wrong? My code…
152
votes
9 answers

Change status bar color with AppCompat ActionBarActivity

In one of my Activities, I changed the Toolbar color using Palette. But on 5.0 devices using ActionBarActivity the status bar color is the color of my colorPrimaryDark in my activity theme so I have 2 very different colors and it does not look…
tyczj
  • 66,691
  • 50
  • 172
  • 271
128
votes
5 answers

How to use SearchView in Toolbar Android

The code on which I am working, is using a Toolbar and inflating a menu. Here is the code private Toolbar mToolbar; mToolbar.inflateMenu(R.menu.chat_screen_menu); setupMenu (); private void setupMenu () { mMenu = mToolbar.getMenu(); if…
Shudy
  • 6,898
  • 15
  • 50
  • 85
125
votes
36 answers

Is it possible to change the textcolor on an Android SearchView?

The SearchView element doesn't have any properties for changing the text color. The default text color is black and doesn't work on our dark background. Is there a way to change the color of the text without resorting to hacks? I found this similar…
CACuzcatlan
  • 5,016
  • 7
  • 40
  • 59
116
votes
13 answers

Creating a Preference Screen with support (v21) Toolbar

I was having trouble using the new Material Design toolbar in the support library on a Preference screen. I have a settings.xml file as below:
113
votes
10 answers

How to get Toolbar from fragment?

I have ActionBarActivity with NavigationDrawer and use support_v7 Toolbar as ActionBar. In one of my fragments toolbar has custom view. In other fragments Toolbar should show title. How get Toolbar instance for customizing from fragments? I can get…
109
votes
8 answers

Creating a button in Android Toolbar

How can I create a button inside Android's Toolbar that looks like this iOS example?
alan_derua
  • 2,094
  • 3
  • 19
  • 19
1
2 3
99 100