I want to add items to my recyclerview and that my scrollbar is updated accordingly.
Here is my RecyclerView :
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:scrollbars="vertical"
android:scrollbarThumbVertical="@color/clear_grey"
android:fadeScrollbars="false"
/>
After adding an element to my dataset, I am calling
recyclerViewAdapter.notifyItemInserted(recyclerViewAdapter.getItemCount() - 1);
The problem is, the scrollbar is not updated : I have to touch the views for it to be updated.
I was using
recyclerViewAdapter.notifyDataSetChanged();
The scrollbar is updated, but I can't use this solution. (I need to be able to select text from the views, which is impossible with notifyDataSetChanged.)
Any ideas on how to update the scrollbar ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…