read
To draw borders we have to understand the basics of layer-list drawable component. An exhaustive guide is provided by Android Developers Guide.
Code snippet to draw top and bottom borders:
res/drawable/border.xml
#How layer list works?
Above code snippet results in a layer with border on all sides. Stroke tag defines the border and Solid tag defines the background colour.
#
This snippet is drawn over the first layer which has top offset 2dp and bottom offset 2dp (border thickness)
#