An Android page indicator which can be used together with a ViewPager widget.
If you find this library useful, you can support its development:
This library is distributed with JitPack.io.
-
Add JitPack to your project's
settings.gradlefile:dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven { url 'https://jitpack.io' } } }For older Gradle versions, add it to your root
build.gradle:allprojects { repositories { //... maven { url 'https://jitpack.io' } } } -
Add the dependency to your app's
build.gradlefile. ReplaceTagwith the latest release version from the releases page.dependencies { implementation 'com.github.firebirdberlin:android-page-indicator:Tag' }
-
Add the JitPack repository to your
pom.xml:<repositories> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories>
-
Add the dependency. Replace
Tagwith the latest release version from the releases page.<dependency> <groupId>com.github.firebirdberlin</groupId> <artifactId>android-page-indicator</artifactId> <version>Tag</version> </dependency>
- Add the page indicator to your layout
<de.firebirdberlin.pageindicator.PageIndicator xmlns:pageindicator="pageindicator" android:id="@+id/page_indicator" android:background="#000000" android:layout_width="match_parent" android:layout_marginTop="5dp" android:layout_marginBottom="5dp" android:layout_height="6dp" pageindicator:color="android:attr/textColor"/> Without specification the default color is the default android text color. You can specify the color using the attribute `pageindicator:color`. Valid values are: - Resources in the form "package:type/name", e.g. "android:attr/textColor" - Colors in HEX-notation, e.g. "#00FF00" The size is determined by the height of the view. - Configure the page indicator in your class:
import de.firebirdberlin.pageindicator.PageIndicator; [...] final PageIndicator pageIndicator = (PageIndicator) findViewById(R.id.page_indicator); pageIndicator.setPageCount(num_pages); pager.setOnPageChangeListener(new OnPageChangeListener() { public void onPageScrollStateChanged(int state) {} public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {} public void onPageSelected(int position) { pageIndicator.setCurrentPage(position); } });