AbrahamCuautle / PageIndicatorView

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PageIndicatorView

Animating Page indicator. It is mainly intended to work with ViewPager2

Screenshot

Installation

Add this in your root build.gradle file:

allprojects {
    repositories {
        maven { url "https://www.jitpack.io" }
    }
}

Then, add the library to your module build.gradle:

dependencies {
    implementation 'com.github.AbrahamCuautle:PageIndicatorView:{latest_version}'
}

Usage

<com.abrahamcuautle.pageindicatorview.PageIndicatorView
        android:id="@+id/pageIndicatorView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:indicator_selected_color="@android:color/holo_green_light"
        app:indicator_unselected_color="@color/design_default_color_primary"
        app:indicator_radius="6dp"
        app:indicator_spacing="8dp"/>

First, you need to set a number of page indicators

   pageIndicatorView.setPageIndicatorsCount(...)

Now you can select a position

  pageIndicatorView.selectPosition(...)

or use PageIndicatorMediator. There is no need to call setPageIndicatorsCount() or selectPosition() by yourself.
Note: you must set an adapter before call PageIndicatorMediator.attach()

    viewpager2.setAdapter(...)
    PageIndicatorMediator(viewpager2, pageIndicatorView).attach()

About


Languages

Language:Java 77.9%Language:Kotlin 22.1%