scroll - Android: How to get the current X offset of RecyclerView? -


i'm using scrollview infinite "time picker carousel" , found out, not best approach (last question)

now, found recycler view i unable current scroll offset in x direction of recyclerview? (let's each item 100px width, , second item visible 50%, scroll-offset 150px)

  • all items have same width, therer gap before first, after last item
  • recyclerview.getscrollx() returns 0 (docs say: initial scroll value)
  • the layoutmanager has findfirstvisibleitemposition, cannot calculate x offset that

update

i found way keep tracking x-position, while updating value onscrolled callback, prefer getting actual value instead of tracking time!

private int overallxscroll = 0; //... mrecyclerview.setonscrolllistener(new recyclerview.onscrolllistener() {         @override         public void onscrolled(recyclerview recyclerview, int dx, int dy) {             super.onscrolled(recyclerview, dx, dy);              overallxscroll = overallxscroll + dx;              log.i("check","overallxscroll->" + overallxscroll);          }     }); 

recyclerview have method horizontal , vertical scroll offset

mrecyclerview.computehorizontalscrolloffset() mrecyclerview.computeverticalscrolloffset() 

this work recyclerviews containing cells of same height (for vertical scroll offset) , same width (for horizontal scroll offset)


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -