Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 回收器视图中每个项目之间的空白_Android_Firebase Realtime Database_Android Recyclerview - Fatal编程技术网

Android 回收器视图中每个项目之间的空白

Android 回收器视图中每个项目之间的空白,android,firebase-realtime-database,android-recyclerview,Android,Firebase Realtime Database,Android Recyclerview,我在应用程序中使用Firebase Recycler,并在片段中实现了代码。数据加载很好,但当我滚动到列表末尾时,每个项目之间会出现空白,只有在从一个活动更改为另一个活动时,这些空白才会清除 我的XML代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://sc

我在应用程序中使用Firebase Recycler,并在片段中实现了代码。数据加载很好,但当我滚动到列表末尾时,每个项目之间会出现空白,只有在从一个活动更改为另一个活动时,这些空白才会清除

我的XML代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
    android:orientation="vertical"
    android:paddingBottom="55dp">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/home_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary">

        <TextView
            android:id="@+id/map_view"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:drawableStart="@drawable/ic_location_on_black_24dp"
            android:drawablePadding="10dp"
            android:ellipsize="end"
            android:fontFamily="@font/roboto_medium"
            android:gravity="center"
            android:maxLines="1"
            android:padding="5dp"
            android:text="@string/text1" />

    </androidx.appcompat.widget.Toolbar>

    <androidx.cardview.widget.CardView
        app:cardCornerRadius="10dp"
        android:layout_margin="14dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <com.smarteist.autoimageslider.SliderView
            android:id="@+id/imageSlider"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            app:sliderAnimationDuration="5000"
            app:sliderAutoCycleEnabled="true"
            app:sliderIndicatorAnimationDuration="5000"
            app:sliderIndicatorGravity="center_horizontal|bottom"
            app:sliderIndicatorMargin="15dp"
            app:sliderIndicatorOrientation="horizontal"
            app:sliderIndicatorPadding="3dp"
            app:sliderIndicatorRadius="1dp"
            app:sliderIndicatorSelectedColor="#5A5A5A"
            app:sliderIndicatorUnselectedColor="#FFF"
            app:sliderScrollTimeInSec="3"
            app:sliderStartAutoCycle="true" />

    </androidx.cardview.widget.CardView>

    <RadioGroup
        android:id="@+id/layout_change_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:gravity="center_horizontal"
        android:orientation="horizontal">


        <RadioButton
            android:id="@+id/btn_for_list1"
            android:layout_width="150dp"
            android:gravity="center"
            android:layout_height="30dp"
            android:background="@drawable/radio_flat_selector"
            android:button="@android:color/transparent"
            android:checked="true"
            android:text="Home Services"
            android:textColor="@color/radio_flat_text_selector" />

        <RadioButton
            android:id="@+id/btn_for_list2"
            android:gravity="center"
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:background="@drawable/radio_flat_selector"
            android:button="@android:color/transparent"
            android:text="Home Improvements"
            android:textColor="@color/radio_flat_text_selector" />

    </RadioGroup>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/main_list1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:layout_marginEnd="10dp"
            android:layout_marginTop="15dp"/>

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/main_list2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="invisible"
            android:layout_marginStart="10dp"
            android:layout_marginEnd="10dp"
            android:layout_marginTop="15dp"/>
    </RelativeLayout>

</LinearLayout>


感谢所有试图回答我问题的人。我只是犯了一个小错误,每个项目之间都有空格

在项目的父布局中。我补充说

android:layout_height:"match_parent"

而不是
wrap\u content
,这就产生了错误。

添加xml和适配器代码。请发布xml和adpter代码,但当我让recyclerview item匹配父项的高度时,这种情况发生在我身上。将xml代码添加到问题中可能是xml布局中的问题。如果您包含android:FitsystemWindows=“true”然后尝试删除它并设置布局高度:wrap\u content用这两个代码更新了我的问题。
android:layout_height:"match_parent"