Android draw a Horizontal line between views
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" />
You should use the new lightweight View Space
to draw dividers.
Your layout will load faster if you will use Space
instead of View
.
Horizontal divider:
<android.support.v4.widget.Space
android:layout_height="1dp"
android:layout_width="match_parent" />
Vertical divider:
<android.support.v4.widget.Space
android:layout_height="match_parent"
android:layout_width="1dp" />
You can also add a background:
<android.support.v4.widget.Space
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="?android:attr/listDivider"/>
Usage example:
....
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="One"/>
<android.support.v4.widget.Space
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="?android:attr/listDivider"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Two"/>
<android.support.v4.widget.Space
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="?android:attr/listDivider"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Three"/>
....
In order to use Space
you should add the dependency in your build.gradle:
dependencies {
compile 'com.android.support:support-v4:22.1.+'
}
Documentation https://developer.android.com/reference/android/support/v4/widget/Space.html