Recycler view inside NestedScrollView causes scroll to start in the middle

后端 未结 11 1032
眼角桃花
眼角桃花 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:31

    I solved such issue by setting:

    
    

    to my view above RecyclerView (which was hidden after unwanted scroll). Try to set this property to your LinearLayout above RecyclerView or to LinearLayout which is container of RecyclerView (helped me in another case).

    As I see in NestedScrollView source it tries to focus the first possible child in onRequestFocusInDescendants and if only RecyclerView is focusable it wins.

    Edit (thanks to Waran): and for smooth scroll don't forget to set yourRecyclerView.setNestedScrollingEnabled(false);

提交回复
热议问题