我需要在我的每个回收器视图项目(从左到右角(下在该项目中的任何特定元素,而是对于整个项目中。(这样,用户更容易查看此特定项目中的哪些元素,以及其他项目的开始(
这是我的项目布局:
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_5sdp"
app:cardCornerRadius="0dp"
app:cardElevation="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark">
<TextView
android:id="@+id/nameView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mike"
android:textColor="@color/colorAccent"
android:textSize="@dimen/_21sdp" />
<ImageView
android:id="@+id/image_delete"
android:layout_width="@dimen/_27sdp"
android:layout_height="@dimen/_27sdp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="@dimen/_4sdp"
android:background="@drawable/ic_delete" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
item_layout.xml
您可以使用View
属性:
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/whiteColor" />
或直接使用recyclerview
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),layoutManager.getOrientation());
recyclerView.addItemDecoration(dividerItemDecoration);
只需在项目适配器的末尾添加视图:
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#FFFFFF"/>
在您的情况下1(cardView in to in to in to in to in to into relativelayout或linearlayout
<RelativeLayout>
<androidx.cardview.widget.CardView>
//your other view
</androidx.cardview.widget.CardView>
</RelativeLayou>
,然后
2(添加cardView端标签的下面的视图(下划线(
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/c"
android:background="@color/white"
/>
或
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/c"
android:background="@color/white"
/>
或
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/c"
android:background="@color/white"
/>