Android studio 回收视图项目之间有巨大的空间
我有一个RecyclerView,它有几个项目。与每行之间的空间尽可能小的项目直接位于彼此下方不同,每个项目之间存在巨大的间隙,如图所示:(很抱歉,图像不太好,我用小手机拍摄) 我的RecyclerView布局文件如下:Android studio 回收视图项目之间有巨大的空间,android-studio,android-recyclerview,Android Studio,Android Recyclerview,我有一个RecyclerView,它有几个项目。与每行之间的空间尽可能小的项目直接位于彼此下方不同,每个项目之间存在巨大的间隙,如图所示:(很抱歉,图像不太好,我用小手机拍摄) 我的RecyclerView布局文件如下: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_
<?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">
<TextView
android:id="@+id/layout_list_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/layout_list_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/layout_list_name"
android:layout_alignLeft="@+id/layout_list_name"
android:layout_below="@+id/layout_list_name" />
<ImageButton
android:id="@+id/layout_list_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:contentDescription="@string/layout_list_delete"
android:src="@drawable/delete" />
如何消除这一巨大的差距?尝试将
布局\u height=“match\u parent”
更改为布局\u height=“wrap\u content”
。这将有望解决您的问题。将父版面的高度更改为wrap\u content
。对于您发布的XML文件,它应该是:
<?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="wrap_content">
请参阅更新的回复帖子,其中包含回收view@jankigadhiya它起作用了吗?