WISHY WISHY - 1 month ago 15
Android Question

Action bar title is not aligning properly, android?

I am using toolbar with in my app

This is my code

toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);


My XML

<android.support.v7.widget.Toolbar
android:id="@+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/appColor"
android:minHeight="?attr/actionBarSize"
app:theme="@style/MyDarkToolbarStyle" />


Styles

<style name="MyDarkToolbarStyle" parent="Widget.AppCompat.Toolbar">
<item name="android:gravity">center_vertical</item>
<item name="popupTheme">@style/PopupMenuStyle</item>
</style>

<style name="PopupMenuStyle" parent="Base.ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">@color/black</item>
<item name="android:gravity">left|center</item>
<item name="android:background">@color/white</item>
</style>


This is how it looks

enter image description here

As you can see the the title text is not aligned either the navigation drawer

Answer

I have also same problem , it solve by using

android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"

For more details read issues on https://code.google.com/p/android/issues/detail?id=77874

Comments