i want to let the recycleview item scroll to top by click one button.and i use
lineLayoutManger.scrollToPositionWithOffset(position,0);
the position is i want to scroll item postion.but when i go into the Activity and have init the adapter.but when i click the buttton to let fifth item scroll to top. but it just on bottom of the screen. if i click the button again it show normal the fifth item is on top.the items are not the same height.
whate should i do.i have search many article.but have no answer.thanks the wrong effect picturesee this picture
Asked
Active
Viewed 359 times
0

Ruan_Lopes
- 1,381
- 13
- 18

empt
- 133
- 1
- 10
2 Answers
0
get linearLayoutManager from your recyclerView List like this:
((LinearLayoutManager) mList.getLayoutManager()).scrollToPositionWithOffset(mPositionToScroll, 0);

Meikiem
- 1,876
- 2
- 11
- 19
-
i do this,but it still not effect,the first time item just can be visible it on tottom of scroll.the recycleview have a header and the item is Imageview Load by Glide – empt Jun 13 '17 at 10:25
0
Please let me know the way you define your recyclerview

Meikiem
- 1,876
- 2
- 11
- 19
-
code`topLayoutManger = new TopLayoutManager(this,LinearLayoutManager.VERTICAL,false); mRecyclerView.setLayoutManager(topLayoutManger); mRecyclerView.addHeaderView(mVHeader); mRecyclerView.addOnScrollListener(scrollListener); mProductDetailAdapter = new ProductDetailAdapter(getApplicationContext()); mProductDetailAdapter.setListener(this); mRecyclerView.setAdapter(mProductDetailAdapter);` – empt Jun 13 '17 at 11:08
-