Pager (especially for ViewPager) indicator in two styles: circle & fraction.

Overview

PagerIndicator

Download

Pager (especially for ViewPager) indicator in two styles: circle & fraction.

Demo

circle fraction

Dependency

implementation 'me.liangfei:pagerindicator:0.0.2'

Usage

Two attributes are provided:

  • app:indicator_type = [fraction | circle].
  • app:indicator_spacing works only for the circle type indicator.

Step 1: add PageIndicator to the bottom of the ViewPager.

<merge xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <me.liangfei.indicator.PagerIndicator
        android:id="@+id/indicator"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginStart="20dp"
        android:gravity="bottom|center_horizontal"
        app:indicator_spacing="5dp"
        app:indicator_type="fraction" />
</merge>

Step 2: pass the ViewPager instance to the PagerIndicator instance.

val pageIndicator = findViewById(R.id.indicator);
pageIndicator.setViewPager(pager);

You can just take PageIndicator as a normal view to make your layout, because it extends LinearLayout.

Check the app module for more details.

dependencies

欢迎关注我的微信公众号(Chinese only)

You might also like...
Android App of Pager

Pager Pager allows you to communicate with people without any infrastructure based services like cellular network or Wifi. We make this possible by tr

A lightweight indicator like in nexus 5 launcher
A lightweight indicator like in nexus 5 launcher

CircleIndicator A lightweight indicator like in nexus 5 launcher Gradle AndroidX dependencies { implementation 'me.relex:circleindicator:2.1.6' }

A spring indicator like Morning Routine guide.
A spring indicator like Morning Routine guide.

SpringIndicator An indicator like Morning Routine guide.It was originally based on BezierDemo. The sample app: click me #Usage Add the dependency to y

A rubber indicator
A rubber indicator

RubberIndicator A rubber indicator for ViewPager Designed by Valentyn Khenkin Here is the CSS version Usage The attributes for RubberIndicator are not

A Page Indicator Lib is realized in a different way.
A Page Indicator Lib is realized in a different way.

#FlycoPageIndicator A Page Indicator Lib is realized in a different way. Support for Android 2.2 and up. ##Demo ####Here is a DemoApk download ##Gradl

Library containing common animations needed for transforming ViewPager scrolling for Android v13+.
Library containing common animations needed for transforming ViewPager scrolling for Android v13+.

ViewPagerTransforms Library containing common animations needed for transforming ViewPager scrolling on Android v13+. This library is a rewrite of the

A custom ViewPager title strip which gives continuous feedback to the user when scrolling
A custom ViewPager title strip which gives continuous feedback to the user when scrolling

SmartTabLayout A custom ViewPager title strip which gives continuous feedback to the user when scrolling. This library has been added some features an

A Material Design ViewPager easy to use library
A Material Design ViewPager easy to use library

MaterialViewPager Material Design ViewPager easy to use library Sample And have a look on a sample Youtube Video : Youtube Link Download In your modul

A different beautiful ViewPager, with quick swipe controls
A different beautiful ViewPager, with quick swipe controls

HollyViewPager Usage Add a HollyViewPager in your layout com.github.florent37.hollyviewpager.HollyViewPager android:id="@+id/hollyViewPager"

Comments
  • updateIndicator NullPointerException

    updateIndicator NullPointerException

    <com.liangfeizc.slidepageindicator.CirclePageIndicator
            android:id="@+id/indicator"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="20dp"
            android:layout_marginLeft="20dp"
            android:layout_marginStart="20dp"
            android:gravity="bottom|center_horizontal"
            app:indicator_spacing="5dp"
            app:indicator_type="fraction" />
    
       将type设置为circle app:indicator_type="circle",首次启动的时候会出现NullPointerException crash,因为找不到mActivePosition item,所以这行代码会出错。
    
    ((ImageView) getChildAt(mActivePosition)).setImageResource(R.drawable.circle_indicator_stroke);
    
    opened by whiskeyfei 2
  • updateIndicator NullPointerException

    updateIndicator NullPointerException

    <com.liangfeizc.slidepageindicator.CirclePageIndicator
            android:id="@+id/indicator"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="20dp"
            android:layout_marginLeft="20dp"
            android:layout_marginStart="20dp"
            android:gravity="bottom|center_horizontal"
            app:indicator_spacing="5dp"
            app:indicator_type="fraction" />
    
       将type设置为circle app:indicator_type="circle",首次启动的时候会出现NullPointerException crash,因为找不到mActivePosition item,所以这行代码会出错。
    
    ((ImageView) getChildAt(mActivePosition)).setImageResource(R.drawable.circle_indicator_stroke);
    

    已经修复在我的分支,希望有更好的解决方案

    opened by whiskeyfei 2
  • SlidePagerActivity not found

    SlidePagerActivity not found

    I followed the ReadMe that explains to add this to the gradle:

    compile 'com.liangfeizc:SlidePageIndicator:1.1.0@aar'

    but after successfully syncing gradle, Android studio can't find the SlidePagerActivity. Am I doing something wrong?

    opened by afjackman 1
  • NPE in API 4.0.4

    NPE in API 4.0.4

    I'm getting that stack, I'm just NPE in API 4.0.4.

    java.lang.Throwable: addInArray at android.view.ViewGroup.addInArray(ViewGroup.java:3786) at android.view.ViewGroup.addViewInner(ViewGroup.java:3740) at android.view.ViewGroup.addView(ViewGroup.java:3564) at android.support.v4.view.ViewPager.addView(ViewPager.java:1341) at android.view.ViewGroup.addView(ViewGroup.java:3509) at android.view.ViewGroup.addView(ViewGroup.java:3485) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:970) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501) at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:490) at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163) at android.support.v4.view.ViewPager.populate(ViewPager.java:1105) at android.support.v4.view.ViewPager.populate(ViewPager.java:951) at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:446) at br.com.ponterionit.activitys.MainActivity.exibeCameras(MainActivity.java:220) at br.com.ponterionit.activitys.MainActivity.access$300(MainActivity.java:32) at br.com.ponterionit.activitys.MainActivity$2.downloadSuccess(MainActivity.java:201) at br.com.ponterionit.download.HttpDownload$1.onPostExecute(HttpDownload.java:29) at br.com.ponterionit.download.HttpDownload$1.onPostExecute(HttpDownload.java:12) at android.os.AsyncTask.finish(AsyncTask.java:632) at android.os.AsyncTask.access$600(AsyncTask.java:177) at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:5299) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641) at dalvik.system.NativeStart.main(Native Method)

    opened by josinaldobarbosa 0
Owner
Fei Liang
微信公众号「老梁写代码」
Fei Liang
Android auto scroll viewpager or viewpager in viewpager

Android Auto Scroll ViewPager ViewPager which can auto scrolling, cycling, decelerating. ViewPager which can be slided normal in parent ViewPager. Att

Trinea 1.7k Dec 10, 2022
Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.

Android ViewPagerIndicator Paging indicator widgets that are compatible with the ViewPager from the Android Support Library to improve discoverability

Jake Wharton 10.2k Jan 3, 2023
An interactive indicator to navigate between the different pages of a ViewPager

Android PagerSlidingTabStrip (default Material Design) This library is not maintained anymore and there will be no further releases. For most of the c

JPARDOGO 2.2k Jan 4, 2023
Android - A ViewPager page indicator that displays the current page number and (optionally) the page count

NumericPageIndicator A ViewPager page indicator that displays the current page number and (optionally) the page count. It can also display buttons to

Manuel Peinado Gallego 253 Nov 16, 2022
Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.

Android ViewPagerIndicator Paging indicator widgets that are compatible with the ViewPager from the Android Support Library to improve discoverability

Jake Wharton 10.2k Jan 5, 2023
UltraViewPager is an extension for ViewPager to provide multiple features in a single ViewPager.

UltraViewPager 中文文档 ProjectUltraViewPager is a ViewPager extension that encapsulates multiple features, mainly to provide a unified solution for multi

Alibaba 5k Dec 20, 2022
Pixplicity 915 Nov 8, 2022
Don't write a ViewPager Adapter! Hook up your ViewPager to your data model using Android Data Binding Framework. With Kotlin support!

Don't write a ViewPager Adapter! Hook up your ViewPager to your data model using Android Data Binding Framework. Show some ❤️ ?? Sweet and short libra

Rakshak R.Hegde 180 Nov 18, 2022
Persons cards list viewpager - Persons cards list viewpager using kotlin

persons_cards_list_viewpager Дизайн и условие взяты из https://github.com/appKOD

Mironov Ury 1 Mar 1, 2022
A pager for Android with parallax effect

ParallaxPagerTransformer A pager transformer for Android with parallax effect Installation in your build.gradle file dependencies { // ... com

Javier Gonzalez 654 Dec 29, 2022