Android: How can I use the layer-list and shape elements to draw a horizontal rule when set as background?

Found the answer before i’d finished asking about it.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
      <shape 
        android:shape="rectangle">
            <stroke android:width="1dp" android:color="@color/hr_bottom" />
            <solid android:color="#00FF0000" />
            <padding android:bottom="1dp"/>
        </shape>
   </item>

   <item>
      <shape 
        android:shape="rectangle">
            <stroke android:width="1dp" android:color="@color/hr_top" />
            <solid android:color="#00FF0000" />
            <padding android:bottom="1dp"/>
        </shape>
   </item>

    <item>
      <shape 
        android:shape="rectangle">
            <stroke android:width="1dp" android:color="#00000000" />
            <solid android:color="#00000000" />
        </shape>
   </item>

</layer-list>

Leave a Comment