如何在操作栏及其下方的布局之间添加水平分隔线

How to add horizontal divider between action bar and layouts beneath it

如何添加分隔线,使其显示在操作栏下方和 master/detail 窗格上方?我已经定义了垂直分隔线,但不知道如何定义水平分隔线。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:divider="@drawable/divider_vertical"
    android:showDividers="middle"
    android:baselineAligned="false"
    tools:context=".MainActivity" >

    <RelativeLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:id="@+id/master_container"/>

    <FrameLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="3"
        android:id="@+id/detail_container"/>

</LinearLayout>

divider_vertical.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <size android:width="1dp"/>
    <solid android:color="#FFFFFF"/>
</shape>

divider_horizontal.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <size android:height="1dp"/>
    <solid android:color="#FFFFFF"/>
</shape>

我没有看到工具栏的代码,所以在我看来,工具栏下方应该有一个视图,如下所示。我用过material设计工具栏,你可以用任何工具栏。

    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:theme="@style/Base.ThemeOverlay.AppCompat.Dark">

</android.support.v7.widget.Toolbar>
            <View android:layout_height="0dp"
                  android:layout_width="fill_parent"
                  android:id="@+id/stripBelowToolbar"/>
<com.google.android.material.appbar.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:elevation="0dp"
    android:theme="@style/Theme.Insider.AppBarOverlay">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:titleTextColor="@color/black"
        android:elevation="0dp"
        android:theme="@style/ToolbarColoredBackArrow"
        android:background="@color/background_tint"
        app:popupTheme="@style/Theme.Insider.PopupOverlay" />
    <View
        android:background="@color/lighter_color"
        android:layout_width="match_parent"
        android:layout_height="2dp"
        />

</com.google.android.material.appbar.AppBarLayout>

这对我有用