如何去除工具栏周围的边框?

How to remove the border around the toolbar?

在我的应用程序中,我使用了一个工具栏,它周围似乎有一些我想去掉的边框:

我是这样创建的:

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/transparent">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_gravity="center"
        android:minHeight="?attr/actionBarSize"/>

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

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

我就是这样使用它的:

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

    <include
        layout="@layout/app_bar_main_light"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

而且我从未找到指定此边框是什么的属性或样式。

我在没有 AppBarLayout 的情况下尝试过,它可以工作。不要使用 AppBarLayout,直接使用 Toolbar。

如果@joyl 的回答有效,但您仍然不想删除您的 AppBarLayout,则在 AppBarLayout 中将 elevation 设置为 0,如下所示:

<com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:elevation="0dp">

这是我的解决方案。

android:stateListAnimator="@null"