android工具栏中的后退箭头按钮未置于中间位置

android工具栏中的后退箭头按钮未置于中间位置,android,android-actionbar,android-toolbar,Android,Android Actionbar,Android Toolbar,我在操作栏中显示了一个后退按钮,但它没有显示在操作栏的中心 如图所示 我已经为工具栏设置了最小高度,无法更改 我的xml代码如下所示: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http:/

我在操作栏中显示了一个后退按钮,但它没有显示在操作栏的中心

如图所示

我已经为工具栏设置了最小高度,无法更改

我的xml代码如下所示:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.design.widget.AppBarLayout
                android:id="@+id/app_bar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:theme="@style/AppTheme.AppBarOverlay">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/offence_title"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:background="?attr/colorPrimary"
                    android:minHeight="150dip"
                    android:paddingBottom="15dp"
                    android:paddingTop="15dp"
                    android:theme="?attr/actionBarTheme"
                    android:paddingRight="15dp">

                    <TextView
                        android:id="@+id/toolbar_title"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:maxLines="3"
                        android:textColor="#FFF"
                        android:textSize="25sp" />
                </android.support.v7.widget.Toolbar>

            </android.support.design.widget.AppBarLayout>

            <TextView
                android:id="@+id/fine_bold"
                style="?android:attr/textAppearanceLarge"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/app_bar"
                android:padding="16dp"
                android:textIsSelectable="true"
                android:textSize="25sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/offence_details"
                style="?android:attr/textAppearanceLarge"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/fine_bold"
                android:padding="16dp"
                android:textIsSelectable="true" />
        </LinearLayout>
    </ScrollView>
</RelativeLayout>

从android.support.v7.widget.Toolbar中删除填充顶部

比如:

您应该将android:layout\u width设置为自定义高度,将android:minHeight设置为?attr/actionBarSize。这样可以确保固定图元沿minHeight内居中的顶部显示,而整个高度仍扩展到更大的高度

<android.support.v7.widget.Toolbar
  android:id="@+id/offence_title"
  android:layout_width="match_parent"
  android:layout_height="150dip"
  android:layout_gravity="center"
  android:gravity="center"
  android:background="?attr/colorPrimary"
  android:minHeight="?attr/actionBarSize"
  android:paddingBottom="15dp"
  android:paddingTop="15dp"
  android:theme="?attr/actionBarTheme"
  android:paddingRight="15dp">
<android.support.v7.widget.Toolbar
  android:id="@+id/offence_title"
  android:layout_width="match_parent"
  android:layout_height="150dip"
  android:layout_gravity="center"
  android:gravity="center"
  android:background="?attr/colorPrimary"
  android:minHeight="?attr/actionBarSize"
  android:paddingBottom="15dp"
  android:paddingTop="15dp"
  android:theme="?attr/actionBarTheme"
  android:paddingRight="15dp">