0

I have a Recycler View that is showing a list of elements. My list has 100 elements and after building the list and load in recycler I need to know how many elements I can see on my screen.

Follow the image below :

enter image description here

I need to know the number of elements that I can see in the list. In that example, following the number of Add Buttons as a reference, They are 4 elements.

Al-Amin
  • 1,369
  • 1
  • 9
  • 26

1 Answers1

3

you can get the on-screen item count as follow

RecyclerView recyclerView = findViewById(R.id.recyclerview);
LinearLayoutManager layoutManager = new LinearLayoutManager(context);
recyclerView.setLayoutManager(layoutManager);

//get on-screen items count.
int currentItems = layoutManager.getChildCount();

//get total items count.
int totalItems = layoutManager.getItemCount();

//get scroll-out items count
int scrollOutItems = layoutManager.findFirstVisibleItemPosition();
Shivam Jamaiwar
  • 524
  • 1
  • 4
  • 14