RecyclerView inside NestedScrollView onBindViewHolder calling for all getItemCount size

后端 未结 4 1774
谎友^
谎友^ 2021-01-04 18:53

When I put RecyclerView inside NestedScrollView then onBindViewHolder is calling for all row like say I have list which has size of 30

4条回答
  •  再見小時候
    2021-01-04 19:17

    But you set android:layout_height for NestedScrollView to wrap_content - here, it's zero by default (because there no content for him at the moment of the declaration). Next, for RecyclerView you set android:layout_height to match_parent - which is at the moment is 0. Thus, all your items have 0 height.

    Thus, you have such situation. Solution: use solution above from @dkarmazi https://stackoverflow.com/a/37558761/3546306 or try to change parameter android:layout_height values.

提交回复
热议问题