相关疑难解决方法(0)

NestedScrollView onBindViewHolder中的RecyclerView调用所有getItemCount大小

当我放入RecyclerView内部NestedScrollView然后onBindViewHolder调用所有行,比如说我有大小为30的列表然后一次onBindViewHolder调用所有30行,即使没有滚动

 RecyclerView list;
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
        list.setLayoutManager(layoutManager);
        layoutManager.setAutoMeasureEnabled(true);
        list.setNestedScrollingEnabled(false);
        list.addItemDecoration(new VerticalSpaceItemDecoration(5));
        list.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)

我的xml是

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    android:scrollbars="none"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">
 <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/grey">
    <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_views"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/info"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:textAlignment="center"

            android:visibility="visible"
           />
Run Code Online (Sandbox Code Playgroud)

但如果我删除NestedScrollView它正常工作.

android android-recyclerview nestedscrollview android-nestedscrollview

9
推荐指数
1
解决办法
1394
查看次数