Recycler view inside NestedScrollView causes scroll to start in the middle

后端 未结 11 1025
眼角桃花
眼角桃花 2020-12-12 10:07

I am getting a weird scrolling behavior when I add a RecyclerView inside a NestedScrollView.

What happens is that whenever the scrollview has more rows than can be s

11条回答
  •  清歌不尽
    2020-12-12 10:30

    In Java code, after initializing your recyclerView and setting the adapter, add this line:

    recyclerView.setNestedScrollingEnabled(false)
    

    You can also try to wrap the layout withing a relativeLayout so that the views stay at the same position but recyclerView (which scroll) is first in xml hierarchy. The last suggestion a desperate attempt:p

提交回复
热议问题