Align text on toolbar with icons

This is how my toolbar looks like. The text seems completely lost.

enter image description here

Here's the code:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:background="@color/blue_grey_900"
    android:gravity="center"
    android:minHeight="?android:attr/actionBarSize"
    app:popupTheme="@style/ToolbarPopup"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:elevation="5dp"/>

      

What causes misalignment?

+3


source to share


2 answers


change the code to android:layout_height="?attr/actionBarSize



+2


source


You can use custom TextView

in your XML, for example:

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@color/blue_grey_900"
android:gravity="center"
android:minHeight="?android:attr/actionBarSize"
app:popupTheme="@style/ToolbarPopup"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:elevation="5dp">

  <TextView
    android:id="@+id/toolbar_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Title"
    android:layout_gravity="center"/>

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

      



Then you can customize it or place the header anywhere you want.

0


source







All Articles