Search code examples
androidxmlandroid-studioandroid-actionbarandroid-drawable

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


How can I add a divider so that it appears underneath the action bar and above the master/detail panes? I've already defined the vertical divider but don't know how to define the horizontal divider also.

<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>

enter image description here


Solution

  • I do not see the code for the toolbar, so in my sense there should be a view below the toolbar as follows. I have used material design toolbar, you may use any toolbar.

        <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"/>