How to make a page indicator for horizontal recyclerview

Any idea how to add page indicator

Any idea how to create a page indicator for recyclerview list ?

  • Action bar - ifRoom option leaving too much space
  • ActionBar goes out of the screen when keyboard shows up
  • What is the difference to getting the location by using Location Manager and Fused Location Provider Api?
  • Difference between the main thread and UI thread
  • AndroidManifest.xml implied vs explicit permissions ( uses-feature vs uses-permission )
  • DrawerLayout - Exception dispatching input event
  • Related posts:

    Android Dialog theme makes icon too light
    android: difference between ACTION_UP and ACTION_POINTER_UP
    TabLayout selected Tab icon is not selected on start up:
    Android ImageView adjusting parent's height and fitting width
    How to type in Android Emulator using PC-Keyboard
    Updating Google Play Services from 8.4.0 to 9.2.1 causes Gradle sync error
  • Transferring ByteArray through Parcel returns NullPointerException
  • Android Compass orientation on unreliable (Low pass filter)
  • Volley and AsyncTask
  • Android USB host mode “soft-mode” drivers for standard class-compliant USB devices
  • Capture image without intent, Gives different output on different devices
  • Recycle ImageView's Bitmap
  • 2 Solutions collect form web for “How to make a page indicator for horizontal recyclerview”

    Instead of using it with RecyclerView, use this library. https://github.com/JakeWharton/ViewPagerIndicator.

    With RecyclerView you can not implement this kind of functionality, or if you want to implement it, you need to customize everything. You need listener for scrolling and getting current position also.

    okay this way works with me so i hope it works with you too, first you have to create another recyclerview for the circles then put this code in the OnScrollListener of the first recycle view

    int[] firstVisibleItemPositions = new int[appList.size()];
                    int[] lastVisibleItemPositions = new int[appList.size()];
    
                    int position = ((StaggeredGridLayoutManager) listView.getLayoutManager()).findFirstVisibleItemPositions(firstVisibleItemPositions)[0];
                    View currentView = circlesList.getChildAt(position);
                    int lastPosition = ((StaggeredGridLayoutManager) listView.getLayoutManager()).findLastVisibleItemPositions(lastVisibleItemPositions)[0];
                    View lastView = circlesList.getChildAt(lastPosition);
                    ImageView circle;
                    if (dx>0) {
                        if (currentView != null && lastPosition != position) {
                            circle = (ImageView) currentView.findViewById(R.id.img);
                            circle.setImageResource(R.drawable.empty_circle);
                        }
                        if (lastView != null && lastPosition != position) {
                            circle = (ImageView) lastView.findViewById(R.id.img);
                            circle.setImageResource(R.drawable.selected_circle);
                        }
                    }else if (dx<0){
                        if (currentView != null && lastPosition != position) {
                            circle = (ImageView) currentView.findViewById(R.id.img);
                            circle.setImageResource(R.drawable.selected_circle);
                        }
                        if (lastView != null && lastPosition != position) {
                            circle = (ImageView) lastView.findViewById(R.id.img);
                            circle.setImageResource(R.drawable.empty_circle);
                        }
                    }
    
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.