Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation drawer icon is not centered vertically (landscape mode, Android)

Im having problems with the new way to use toolbar. In landscape mode, toolbar title is centered vertically but the navigation drawer not. How can I solve this?

I am using the toolbar like in this post of Chris Banes: AppCompat v21 — Material Design for Pre-Lollipop Devices!

This is the code for the drawer icon in style.xml:

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@android:color/white</item>
</style>

And this is an image of the problem: Landscape image

EDIT: Overflow button is not centered vertically too...

like image 436
JavierSegoviaCordoba Avatar asked Jan 21 '15 11:01

JavierSegoviaCordoba


2 Answers

This is my toolbar theme and everything is centered correctly:

<android.support.v7.widget.Toolbar
    android:layout_width="match_parent"
    android:layout_height="?actionBarSize"
    style="@style/Widget.MyApp.Toolbar">

</android.support.v7.widget.Toolbar>

The example says to use android:minHeight="?actionBarSize" and android:_layout_height="wrap_content" but it only produced the error you described.

like image 139
Eugen Pechanec Avatar answered Nov 13 '22 03:11

Eugen Pechanec


Add this in your toolbar style:

<item name="maxButtonHeight">?attr/actionBarSize</item>

This allows you to use wrap_content height and still have a centered icon!

like image 39
Tytanium Avatar answered Nov 13 '22 02:11

Tytanium