CHollman82
CHollman82

Reputation: 616

Specifying a border for a layout in xml with only the left and right edge visible

I currently use the rectangle shape xml tag to specify borders for my views like so:

<?xml version="1.0" encoding="utf-8"?>
  <shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <stroke android:width="1dp" android:color="#FF000000"/> 
    <padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp"/>
    <solid android:color="#DDDDDD"/>
  </shape> 

This works well for normal borders on all 4 edges of the view but what I would like is for something similar that only shows the border line on the left and right edges of the view and has no line on the top or bottom... I looked into the line drawable in the shape class but it seems it can only do horizontal lines, can that be right? Why wouldn't you be able to specify vertical lines?

Is there a better way to do this?

Thanks.

Upvotes: 1

Views: 643

Answers (1)

Mahdi Hijazi
Mahdi Hijazi

Reputation: 4454

Use 9-patch image with borders on the left & right sides and transparent space in between. That would generate your effect.

Upvotes: 1

Related Questions