tags:

views:

1903

answers:

3
+2  A: 

You can create a 9-patch drawable.

Tughi
+5  A: 

The best approach here is to convert the image you have shown as a 9-patch, add it to the res/drawable folder as a resource and display it within your layout using an ImageView, setting android:width="fill_parent".

9-patch images let you specify an area of the image to stretch when the image is resized (in this case the entire image - though you may want to consider 'fading out' the line at its edges to conform to some of the native Android styles).

Within your layout file the ImageView definition would look something like this:

<ImageView
  android:src="@drawable/my_separater_nine_patch"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:scaleType="fitXY"
/>
Reto Meier
+1  A: 

You can create a 2 views, one for each line, set the background color of that view to whatever you want the colors to be, and then set the hieght to 1px and the width to "fill_parent". The advantage of this over the 9 patch approach is that you don't need to load a resource and you can dynamically change the colors to whatever the user wants. The downside is that you are creating a few more layout objects.

hacken