InstaDotView is a customizable dot indicator for Android that can be used to display the current page in a view pager.
Add JitPack to your root build.gradle
file:
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
Add the following dependency in your app's build.gradle:
dependencies {
implementation 'com.github.AnurupJaiswal:InstaDotIndicatorLibrary:1.0.0'
}
In your XML layout file, add the InstaDotView with the attributes of your choice:
<com.anurupjaiswal.instadot.InstaDotView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:dot_activeColor="@color/colorAccent"
app:dot_activeSize="10dp"
app:dot_inactiveColor="@color/colorPrimaryDark"
app:dot_inactiveSize="8dp"
app:dot_margin="10dp"
app:dot_mediumSize="6dp"
app:dot_smallSize="4dp" />
[REQUIRED] Set the number of pages using:
instaDotViewInstance.onPageChange(pageNo)
[REQUIRED] update dot on page change:
instaDotViewInstance.onPageChange(pageNo)
[OPTIONAL] Set Number of Visible Items You can set the number of visible items (must be greater than the default value of 6):
instaDotViewInstance.setVisibleDotCounts(pages)
<attr name="dot_activeColor" format="color" />
<attr name="dot_inactiveColor" format="color" />
<attr name="dot_activeSize" format="dimension" />
<attr name="dot_inactiveSize" format="dimension" />
<attr name="dot_mediumSize" format="dimension" />
<attr name="dot_smallSize" format="dimension" />
<attr name="dot_margin" format="dimension" />
<attr name="dots_visible" format="integer" />