Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.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 可扩展自定义CardView不显示Firebase中RecyclerView的所有内容_Android_Xml_Firebase Realtime Database_Android Recyclerview_Android Cardview - Fatal编程技术网

Android 可扩展自定义CardView不显示Firebase中RecyclerView的所有内容

Android 可扩展自定义CardView不显示Firebase中RecyclerView的所有内容,android,xml,firebase-realtime-database,android-recyclerview,android-cardview,Android,Xml,Firebase Realtime Database,Android Recyclerview,Android Cardview,我正在使用CardView创建可扩展项,其中显示Firebase信息。我测试了Firebase实现,效果很好,下面是屏幕截图: 创建可扩展的CardView后,如下所示: <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.andro

我正在使用CardView创建可扩展项,其中显示Firebase信息。我测试了Firebase实现,效果很好,下面是屏幕截图:

创建可扩展的CardView后,如下所示:

<androidx.constraintlayout.widget.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"
    tools:context=".campus">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/purple_200"
        android:elevation="4dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:title="Кампус" />

    <androidx.cardview.widget.CardView
        android:id="@+id/cardView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/toolbar">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/purple_200"
            android:paddingBottom="8dp">

            <ImageView
                android:id="@+id/groupImage"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginStart="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginTop="8dp"
                android:layout_marginBottom="8dp"
                android:scaleType="centerCrop"
                android:src="@drawable/ic_apartment"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/groupName"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_marginStart="16dp"
                android:ellipsize="end"
                android:gravity="center_vertical"
                android:justificationMode="inter_word"
                android:lines="1"
                android:text="Parent"
                android:textColor="@color/white"
                android:textSize="16sp"
                android:textStyle="bold"
                app:layout_constraintBottom_toBottomOf="@+id/groupImage"
                app:layout_constraintStart_toEndOf="@+id/groupImage"
                app:layout_constraintTop_toTopOf="@+id/groupImage" />

            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/expandableView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingBottom="12dp"
                android:layout_marginTop="12dp"
                android:visibility="gone"
                app:layout_constraintTop_toBottomOf="@+id/groupImage"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent">

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/childRecycler"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintBottom_toBottomOf="@id/expandableView"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/expandableView" />
            </androidx.constraintlayout.widget.ConstraintLayout>
        </androidx.constraintlayout.widget.ConstraintLayout>
    </androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
但它没有正常工作。展开CardView后,它仅显示RecyclerView的一个元素。以下是此的屏幕截图:


如何显示所有RecyclerView内容?还有其他方法吗?

1->重新格式化您的卡,使其适合合理的屏幕大小。这将需要您根据您的视图和想要显示的内容对其进行修补,您还可以使用
省略号将其切断,并使用
onClickListener
设置在卡上显示详细信息

2->添加一个
HorizontalScrollView
作为
RecyclerView
/
CardView
的父视图,以便可以左右滚动

<android.widget.HorizontalScrollView>
      <!-- your params here-->
      <androidx.cardview.widget.CardView>
                 <!-- your params here-->
      </androidx.cardview.widget.CardView>
</android.widget.HorizontalScrollView>


你能告诉我怎么做吗?我已经更新了我的答案,你不明白我的问题。我想让CardView扩展并显示回收器视图的所有上下文,它有2个子项(如第一个屏幕截图所示),但在可扩展的CardView中,它只显示1个子项(第二个屏幕截图)。
<android.widget.HorizontalScrollView>
      <!-- your params here-->
      <androidx.cardview.widget.CardView>
                 <!-- your params here-->
      </androidx.cardview.widget.CardView>
</android.widget.HorizontalScrollView>