对,你可以像你那样在布局行中放置一个分隔符,但你必须纠正它
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center_vertical"
android:background="@color/windowBackground"
android:padding="2dp" >
<RelativeLayout
android:id="@+id/row_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true" >
<TextView android:id="@+id/tvtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Medium" />
<TextView android:id="@+id/tvdescription"
android:layout_below="@id/tvtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Small" />
</RelativeLayout>
<!-- This is Supposed to be the divider -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/row_id"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="@color/yourColor" >
</RelativeLayout>
</RelativeLayout>
或者更简单的方法是从除法中获取listView并在其上放置一个除法
getListView().setDividerHeight(heightOfDivider);
getListView().setDivider(yourDrawable);
如果有任何问题,请留言
祝你好运