0
我是Android應用開發中的新成員。我在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>
從你貼在我看來,佈局要與不是** **的ListView向achiveve這一點,但一** ** RecyclerView。這很重要,因爲他們的行爲和技巧非常不同。所以你應該編輯你的問題(用recyclerview替換listview)並刪除listview標籤。 – nvi9