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:

3112 questions
70
votes
8 answers

Toolbar image centered

Using the last android.support.v7.widget.Toolbar I want to center an image in the toolbar but it keeps staying on the left. The best way for me would be to use toolbar.setLogo() method and to center the logo but i don't see any way to do it. I use a…
Nicolas Hauzaree
  • 743
  • 1
  • 5
  • 9
68
votes
7 answers

Navigation Drawer Below Toolbar

I am trying to get the navigation drawer to open below the…
safaiyeh
  • 1,655
  • 3
  • 16
  • 35
66
votes
9 answers

android.view.View$OnUnhandledKeyEventListener

I am new to Android Studio and I don't get why my toolbar isn't shown as described by https://developer.android.com/training/appbar/setting-up I know there are already some other questions like mine on stackoverflow but they don't work at my…
David Schmidt
  • 758
  • 1
  • 5
  • 7
66
votes
2 answers

Remove elevation shadow without removing elevation itself

Is there a way for AppBarLayout to no drop shadow and keep its elevation?
66
votes
17 answers

Need to disable expand on CollapsingToolbarLayout for certain fragments

I have an AppCompatActivity that controls replacing many fragments. Here is my layout for it. activity_main.xml
65
votes
9 answers

Fix bottom bar in CoordinatorLayout

I have a CoordinatorLayout which contains AppBarLayout and a FrameLayout which contains fragments. One of this fragment contains a TabLayout at Top, one List trough RecyclerView and at the Bottom one "homemade" toolbar. The AppBarLayout is…
Hanzo
  • 1,839
  • 4
  • 30
  • 51
65
votes
5 answers

Toolbar will not collapse with Scrollview as child of CoordinatorLayout

I am trying to follow the Google Docs on using the CoordinatorLayout but i am having an issue with the ScrollView inside the CoordinatorLayout. Basically, the Toolbar normally would collapse with a RecyclerView or a Listview when scrolling down. Now…
63
votes
13 answers

Android - Switch ActionBar Back Button to Navigation Button

I am having the following problem: I know how to set up a toolbar to show a back button icon instead of a burger button icon. From this: to this: using: getSupportActionBar().setDisplayHomeAsUpEnabled(true); Now, I want to do the reverse action,…
63
votes
4 answers

How to add buttons like refresh and search in ToolBar in Android?

I have made a ToolBar, but when I add menu items in menu.xml it always shows as an overflow. How do I add it separately? Moreover the Title is shown in the middle (vertically), how do I show it at the top? menu.xml
kunal.c
  • 2,739
  • 1
  • 18
  • 24
62
votes
2 answers

How can I align Android Toolbar menu/icons to the left like in Google Maps app?

Here is a screenshot of Google Maps Toolbar. As you can see icons are aligned to the left instead of right (default behavior). I've tried adding android:layout_gravity="left" and android:gravity="left" to the toolbar but it didn't work. I also…
62
votes
11 answers

Manage toolbar's navigation and back button from fragment in android

All of my fragments are controlled through ActionBarActivity (mainActivity), inside mainActivity a DrawerLayout is implemented and all the child fragments are pushed through drawerLayout's list item click. The problem that I'm facing is after…
61
votes
1 answer

Toolbar.inflateMenu seems to do nothing

Im currently messing arround with the new AppCompat library bringing material design to older devices. Setting a toolbar as actionbar works fine for me, but the toolbar seems to not do anything on calling inflateMenu(int resId). From the docs, i…
danijoo
  • 2,823
  • 4
  • 23
  • 43
59
votes
10 answers

Should we replace Action Bar by ToolBar?

I have been using ToolBar since it was added into Support v7 library. And I think I used it well. But there is a point I can't understand. Why would Google create such a widget? I mean we can do anything ToolBar can do by using ActionBar. Why do we…
SilentKnight
  • 13,761
  • 19
  • 49
  • 78
59
votes
3 answers

Android v7 Toolbar button alignment

I added android.support.v7.widget.Toolbar in my app using below code, now I want to show a button in the right end of the toolbar, but not able to do so.
54
votes
7 answers

How to display and set click event on Back Arrow on Toolbar?

How can I set back arrow in Android toolbar and also apply click listener?