0

For my app, I'm using Recycler view (androidx.recyclerview.widget.RecyclerView) wrapped inside NestedScrollView (androidx.core.widget.NestedScrollView) as apart from listview data, I wanted to show few more individual data elements.

Scrolling is working fine, but autoscrolling recycler view to some specific index position is not at all happening.

 <androidx.core.widget.NestedScrollView> 
    <LinearLayout> 
     <View/> //some more views 
     <androidx.recyclerview.widget.RecyclerView/> 
    </LinearLayout> 
 </androidx.core.widget.NestedScrollView> 

Also, tried using the below-

    recyclerList.apply 
    { 
    recyclerList.layoutManager = LinearLayoutManager(activity)
recyclerList.isNestedScrollingEnabled = false 
val adapter = RecyclerAdapter(context,dataList) 
recyclerList.adapter = adapter recyclerList.smoothScrollToPosition(dataList.size() - 1)//auto scroll to the bottom 
    } 

The above code snippet is not autoscrolling the recycler view to the last item of the list. Please suggest.

Already tried answers -

  1. How to fix the scroll behaviour of Android androidx.recyclerview.widget.RecyclerView view with androidx.core.widget.NestedScrollView

  2. https://github.com/googlesamples/android-RecyclerView/issues/27

  • Use in _run()_ method of recyclerview using `recyclerList.post(){....` – Piyush Aug 05 '19 at 13:11
  • @Piyush are you suggesting to use something like this? - recyclerList.post{ recyclerList.layoutManager = LinearLayoutManager(activity) recyclerList.isNestedScrollingEnabled = false val adapter = RecyclerAdapter(context,dataList) recyclerList.adapter = adapter recyclerList.smoothScrollToPosition(dataList.size() - 1)} – Shraddha Wankar Aug 05 '19 at 13:17
  • Yes. But not whole part . Only _recyclerList.smoothScrollToPosition(dataList.size() - 1)_ snippet – Piyush Aug 05 '19 at 13:18
  • tried the same, but this also seems be to not autoscrolling the list as expected. – Shraddha Wankar Aug 05 '19 at 13:20

0 Answers0