I have My Layout like below:
----> Simple one
<TextView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#c0c0c0"
android:id="@+id/your_id"
android:layout_marginTop="160dp" />
It will draw Silver gray colored Line between TextView
& ListView
<TextView
android:id="@+id/textView1"
style="@style/behindMenuItemLabel1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:text="FaceBook Feeds" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#c0c0c0"/>
<ListView
android:id="@+id/list1"
android:layout_width="350dp"
android:layout_height="50dp" />
Creating it once and using it wherever needed is a good idea. Add this in your styles.xml:
<style name="Divider">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item>
<item name="android:background">?android:attr/listDivider</item>
</style>
and add this in your xml code, where a line divider is needed:
<View style="@style/Divider"/>
Originally answered by toddles_fp to this question: Android Drawing Separator/Divider Line in Layout?
Try this
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="?android:attr/listDivider"/>
If you does not want to use an extra view just for underlines. Add this style on your textView
.
style="?android:listSeparatorTextViewStyle"
Just down side is it will add extra properties like
android:textStyle="bold"
android:textAllCaps="true"
which you can easily override.
Create Horizontal line
If your are using TextView and then you want to put a Line then use View this way and you can use any color like Blue, Red or black mentioning background color.
<view
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black"></view>