Android bicolor horizontal line

The graphic designer of the Android application I'm creating now came up with a two-color line as a separator between the elements in the layout:

two-color dividing line http://img7.imageshack.us/img7/3351/twocolorline.png

If you look carefully at the image, you will see a dark gray canvas, and at the bottom below - a very light gray (almost white) line. Lines must be resized to the width of the container.

What is the best way to implement this in the user interface?

+5
source share
4 answers

, 9-patch, res/drawable ImageView, android:width="fill_parent".

9-- , , ( ), "" , Android).

ImageView :

<ImageView
  android:src="@drawable/my_separater_nine_patch"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:scaleType="fitXY"
/>
+11

9-, LayerList.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape >
            <solid android:color="#ffffff" />
        </shape>
    </item>
    <item android:bottom="1px">
        <shape >
            <solid android:color="#252525" />
        </shape>
    </item>

</layer-list>
+7
<ImageView android:layout_width="match_parent" android:id="@+id/line1"
            android:layout_height="1dp" android:background="#FFFFFF"
            android:layout_weight="1" android:layout_marginTop="5dp"
            android:layout_marginBottom="5dp" android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"/>

LinearLayout view

+3

You can create 2 views, one for each row, set the background color of this view to what you want the colors to be, and then set hieght to 1px and the width to "fill_parent". The advantage of this approach based on 9 patches is that you do not need to download the resource, and you can dynamically change the colors to whatever the user wants. The downside is that you create a few more layout objects.

+1
source

All Articles