簡體   English   中英

android studio中沒有全寬工具欄?

[英]Not full width toolbar in android studio?

我在我的應用程序中使用工具欄,我將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>

謝謝!

ToolBar添加以下屬性以刪除左邊距。

 app:contentInsetLeft="0dp"
 app:contentInsetStart="0dp"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM