Android 如何删除工具栏中的空间

Android 如何删除工具栏中的空间,android,xml,toolbar,Android,Xml,Toolbar,我想删除工具栏和文本视图之间的空间,如下图所示: 我尝试使用用户contentInsetStart和contentInsetEnd,但也不起作用。 这是我处理它的全部代码 <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="@dimen/app_bar_height" android:theme="@style/

我想删除工具栏和文本视图之间的空间,如下图所示:

我尝试使用用户
contentInsetStart
contentInsetEnd
,但也不起作用。 这是我处理它的全部代码

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="@dimen/app_bar_height"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/ctl_news"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleTextAppearance="@style/CollapsingToolbarLayoutExpandedTextStyle"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:id="@+id/iv_news_mainImage"
            android:layout_width="match_parent"
            android:layout_height="230dp"
            android:scaleType="centerCrop"
            android:src="@drawable/stripes"
            app:layout_collapseMode="parallax"
            app:layout_collapseParallaxMultiplier="0.7" />

        <android.support.v7.widget.Toolbar
            android:id="@+id/tb_news"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:layout_collapseMode="pin"
            android:contentInsetEnd="0dp"
            android:contentInsetStart="0dp"
            app:contentInsetEnd="0dp"
            app:contentInsetStart="0dp"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:titleTextAppearance="@style/Toolbar.TitleText">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/back"
                android:gravity="top|end"
                android:textColor="@color/white"
                android:textSize="@dimen/text_huge_size" />
        </android.support.v7.widget.Toolbar>

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

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


有人能帮我解决这个问题吗

你是否尝试过
app:titleMarginStart=“0dp”


您应该使用
app
前缀作为
contentInsetStart
contentInsetEnd
的前缀,并删除android以避免样板代码

使用app名称空间并执行以下操作:

app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        app:contentInsetLeft="0dp"
        app:contentInsetStart="0dp"
        app:contentInsetStartWithNavigation="0dp"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />
此外,您可能需要添加:

app:contentInsetStartWithNavigation="0dp"
删除contentInsetEnd属性。我试过了,效果很好

看起来是这样的:

app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        app:contentInsetLeft="0dp"
        app:contentInsetStart="0dp"
        app:contentInsetStartWithNavigation="0dp"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />


我也尝试了,但不起作用也删除了
android
前缀和相同的结果你尝试了
app:contentInsetStartWithNavigation
了吗?app:contentInsetStartWithNavigation对我有效。使用重力。!或者在文本视图中对齐父中心,尝试
android:gravity=“left”