I use Scrollview for the infinite "Timer Carousel" and found out that this is not the best approach ( last question )
Now I have found Recycler View , but I canβt get the current scroll offset in the X direction of the recyclerView ? (Letβs say that each element has a width of 100 pixels, and the second is only 50% wide, so the scroll offset is 150 pixels)
- all elements have the same width, but therer is some space before the first, after the last element
recyclerView.getScrollX() returns 0 (say: initial scroll value)LayoutManager has findFirstVisibleItemPosition , but I cannot calculate the X offset with this
UPDATE
I just found a way to track the X-Position by updating the value with the onScrolled , but I would rather get the actual value, rather than keep track of it all the 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); } });
android scroll position android-recyclerview
longilong Dec 16 '14 at 15:10 2014-12-16 15:10
source share