Skip to content

4. Cell and Header Dividers

Zardozz edited this page Mar 21, 2021 · 1 revision

One method of creating cell and header dividers is by adding scalable drawable shapes to the background of various views with setBackgroundResource method.
e.g.

  • Cell Divider
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    <solid android:color="@android:color/transparent" />
    <stroke android:width="1px" android:color="#C5CAE9"/>
</shape>
  • Column Header
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/black" />
        </shape>
    </item>
    <item android:bottom="3dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/white" />
        </shape>
    </item>
</layer-list>
  • Row Header
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/black" />
        </shape>
    </item>
    <item android:right="3dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/white" />
        </shape>
    </item>
</layer-list>
  • Corner
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/black" />
        </shape>
    </item>
    <item android:right="3dp" android:bottom="3dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/white" />
        </shape>
    </item>
</layer-list>

The background colour or colours of the background shapes for the Column Header, Row Header and Corner Tables should never be transparent as the Main Table slides under these when scrolling and if they were transparent you would see the Main table under them.