Is there a way to change the scroll counter reference of recyclerView to start from the center of the screen, and not from the beginning? So that, when I call linearLayoutManager.findFirstVisibleItemPosition() I get the position of the item in the screen center and not at the start of the screen?
Change recyclerView scroll position reference
92 views Asked by Mohammed Alramlawi At
2
There are 2 answers
0
On
I have got the solution for this issue, I simply override getPaddingLeft(), getPaddingEnd() methods as below.
private fun setupLinearManager(context: Context) {
linearLayoutManager = object : LinearLayoutManager(context, HORIZONTAL, false) {
override fun getPaddingLeft(): Int {
return screenWidth / 2
}
override fun getPaddingEnd(): Int {
return screenWidth / 2
}
}
recyclerView.layoutManager = linearLayoutManager
}
Your question is not clear enough! but I think
clipToPadding = trueandpaddingBottomcan solve your problem with recyclerView I understood your problem correctly