r-cohen / DiscreteScrollViewIndicator

A page indicator for DiscreteScrollView Android component
Apache License 2.0
2 stars 1 forks source link
android decorator discretescrollview indicator

DiscreteScrollViewIndicator

A page indicator for DiscreteScrollView Android library

Simple Usage

DiscreteScrollViewIndicator pageIndicator = DiscreteScrollViewIndicator.Builder(discreteScrollView);
discreteScrollView.addItemDecoration(pageIndicator);

Customize

float DP = Resources.getSystem().getDisplayMetrics().density;
DiscreteScrollViewIndicator pageIndicator = DiscreteScrollViewIndicator.Builder(discreteScrollView)
    .setColorActive(getColor(R.color.ap_white))
    .setColorInactive(getColor(R.color.pagerItem))
    .setIndicatorStrokeWidth(4 * DP)
    .setIndicatorItemPadding(10 * DP)
    .align(DiscreteScrollViewIndicator.Alignment.PARENT_TOP)
    .matchParentWidth();
discreteScrollView.addItemDecoration(pageIndicator);

Usage with InfinitePagerAdapter & InfiniteScrollAdapter

The indicator automatically attempts to fetch the number of items through the adapter unless you set it manually as follows.

pageIndicator.setItemsCount(itemsCount);

Inspired by

bleeding182's recyclerviewItemDecorations