android studio 中不是全宽工具栏?

use*_*943 5 xml android toolbar textview android-layout

我在我的应用程序中使用工具栏,我将 TextView 自定义到工具栏的中心,但它不是工具栏屏幕的全宽,并在左侧保持一个小屏幕,如下图所示。那么我该怎么做才能使自定义 TextView 位于屏幕和工具栏的中心?

我目前的屏幕问题:

在此处输入图片说明

我想要的屏幕:

在此处输入图片说明

<?xml version="1.0" encoding="utf-8"?>
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@color/colorPrimary"
        app:theme="@style/ThemeOverlay.AppCompat.Dark"
        xmlns:app="http://schemas.android.com/apk/res-auto">
        <TextView
            android:id="@+id/tv_title"
            android:textColor="#FFF"
            android:background="#F00"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="TITLE"
            android:textStyle="bold"
            android:textSize="15sp"
            android:gravity="center"/>
    </android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)

谢谢!

Har*_*iya 5

在您ToolBar添加以下属性以删除左填充。

 app:contentInsetLeft="0dp"
 app:contentInsetStart="0dp"
Run Code Online (Sandbox Code Playgroud)