3

I need to have first row(and values of row) always when I scrolling. I have a RecyclerViewI need that when I scrolling my recycle and when arrive Row eight to position of Row one I visible a TextView for shown a something, for example a Title. How I can mange it?

enter image description here

For example when yellow row arrive to position of row green I visible a TextView.

enter image description here

I don't know how I can get position first row of Layout from Activity.

NOTICE : I don't need to use libraries of GitHub. Thanks

1 Answers1

1

first / last visible child depends on the LayoutManager. If you are using LinearLayoutManager or GridLayoutManager, you can use

int findFirstVisibleItemPosition();
int findFirstCompletelyVisibleItemPosition();
int findLastVisibleItemPosition();
int findLastCompletelyVisibleItemPosition();

For example:

GridLayoutManager layoutManager = ((GridLayoutManager)mRecyclerView.getLayoutManager());
int firstVisiblePosition = layoutManager.findFirstVisibleItemPosition();
cw fei
  • 1,534
  • 1
  • 15
  • 33