【发布时间】:2018-07-18 02:28:34
【问题描述】:
我有 3 级列表,我想在 3 级嵌套回收器视图中表示此列表。 因此,我设置了 3 个适配器并将其调整为像这样的 3 个回收器视图 第一级:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txt_threshold_name"
android:background="@android:color/holo_red_light"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rv_threshold_list_level_1"
android:layout_marginLeft="@dimen/pd_14"
/>
</LinearLayout>
二级
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rv_threshold_list_level_2"
/>
</LinearLayout>
第三级:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rv_threshold_list_level_3"
android:layout_marginLeft="@dimen/pd_14"
/>
</LinearLayout>
我像往常一样设置每个回收站视图。
LinearLayoutManager layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setClipToPadding(false);
mRecyclerView.setHasFixedSize(false);
但 2 级和 3 级回收站视图并未准确显示数据。它只显示了 2 级回收器视图的第一项,但下一项的背景仍然存在:
我想知道我是否错过了一些回收站设置以使其正常工作。 请帮帮我!
【问题讨论】:
-
如果您尝试使用固定高度,这将有助于调试问题...您可以尝试为每个回收站视图使用高度为 100
标签: android android-layout android-studio android-recyclerview recyclerview-layout