Scroll Recyclerview Item To Top Inside Of Scroll View
I'm trying to scroll recycler view item to top of screen when user clicks on an item. My layout is set as following - -- ---
Solution 1:
Looks like in your case you don't have enough items.
You can't get recyclerView scroll lower than the last Item So it's either you make your own implementation of recyclerView by extending it,get add scroll amounts and when got to the last item you'll add up the translationY of the recyclerView.
Or you can add a few dummy Items.So they can be View with width and height of your normal Items.That should do it.
Solution 2:
Have you tried layoutManager's scrollToPositionWithOffset
function:
thirdItem.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View v) {
LinearLayoutManagerlayoutManager= (LinearLayoutManager) mRecyclerView
.getLayoutManager();
layoutManager.scrollToPositionWithOffset(0, 0);
}
});
Post a Comment for "Scroll Recyclerview Item To Top Inside Of Scroll View"