android studio 中不是全宽工具栏?
Not full width toolbar in android studio?
我在我的应用程序中使用工具栏,我将 TextView 自定义到工具栏的中心,但它不是工具栏屏幕的全宽,并且在左侧保留了一个小屏幕,如下图所示。那么如何才能让自定义TextView居中于屏幕和Toolbar呢?
我目前的屏幕问题:
我想要的屏幕:
<?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>
谢谢!
在您的 ToolBar
下方添加 属性 以移除左内边距。
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
我在我的应用程序中使用工具栏,我将 TextView 自定义到工具栏的中心,但它不是工具栏屏幕的全宽,并且在左侧保留了一个小屏幕,如下图所示。那么如何才能让自定义TextView居中于屏幕和Toolbar呢?
我目前的屏幕问题:
我想要的屏幕:
<?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>
谢谢!
在您的 ToolBar
下方添加 属性 以移除左内边距。
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"