将 recyclerview 的背景颜色设置为白色,并将分隔线的颜色设置为与背景图像相同

set background color as white of recyclerview and divider line's color as same as background image

我是 android 应用程序的新手 development.I 正在 android-studio 中制作一个项目。我想将列表视图的颜色设置为白色,分隔线的颜色与背景颜色相同image.My代码如下

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"

android:background="@android:color/transparent"
tools:context="com.example.litifer.litiferdemo.MainActivity">
<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/imageView"
    android:src="@drawable/images1"/>
<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"></android.support.v7.widget.RecyclerView</android.support.constraint.ConstraintLayout>

list_item.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
    android:layout_margin="@dimen/cardview_default_radius"
    android:layout_width="match_parent"
    android:background="#FFFFFF"
    android:layout_height="wrap_content"></android.support.v7.widget.CardView>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textViewHead"
        android:text="Heading"
        android:textSize="20dp"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="60dp"
        android:layout_marginRight="40dp"
        android:textAppearance="@android:style/TextAppearance.Large"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textViewDesc"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="60dp"
        android:layout_marginRight="40dp"
        android:text="Description"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="60dp"
        android:layout_marginRight="40dp"
        android:id="@+id/textViewDate"
        android:text="Date"/>
</LinearLayout></LinearLayout>

您可以像 link 附上的那样使用物品装饰 link

您终于可以将视图添加到您的布局中了

<View

        android:layout_width="match_parent"
        android:layout_height="@dimen/normal_margin1"
        android:layout_marginTop="@dimen/normal_margin8"
        android:background="@color/black12" />