我在另一个再循环视图(使用LinearLayoutManager)中有一个垂直回收器视图(带有GridLayoutManager).我现在遇到的问题是,内部的回收器视图(与GridLayoutManager)同时绑定所有的项目,甚至当前不在屏幕上的视图(onBindViewHolder()被调用它的所有项目).
@H_301_2@为了给你更多的信息,在我的布局文件中,我把回收器视图的高度设为wrap_content.
@H_301_2@我认为问题是,由于有2个嵌套的垂直回收器,当父RV想要测量其孩子并且孩子是另一个RV时,在onMeasure()中,它计算整个RV所需的大小,而不仅仅是它的部分想绑定在屏幕上.
@H_301_2@任何想法如何解决?
@H_301_2@这是我的外部回收器视图的布局文件:
https://github.com/sockeqwe/AdapterDelegates
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/component_list" android:layout_width="match_parent" android:layout_height="match_parent"/> </FrameLayout>@H_301_2@这里是我内部回顾者视图的代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/container" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="@dimen/gutter" android:paddingBottom="@dimen/gutter"> <TextView android:id="@+id/title_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/gutter" android:textSize="30sp" android:textColor="@android:color/white" android:fontFamily="sans-serif-thin"/> <android.support.v7.widget.RecyclerView android:id="@+id/my_slider" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout>@H_301_2@P.S .:我正在使用这个适配器委托作为我的外部回收器视图:
https://github.com/sockeqwe/AdapterDelegates