- Notifications
You must be signed in to change notification settings - Fork568
An page indicator for Android ViewPager
romandanylyk/PageIndicatorView
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
PageIndicatorView is light library to indicate ViewPager's selected page with different animations and ability to customise it as you need.
To addpageindicatorview to your project, first make sure in rootbuild.gradle you have specified the following repository:
repositories { jcenter() }Note: by creating new project in Android Studio it will have
jcenterrepository specified by default, so you will not need to add it manually.
Once you make sure you havejcenter repository in your project, all you need to do is to add the following line independencies section of your projectbuild.gradle.
implementation'com.romandanylyk:pageindicatorview:X.X.X'If your project already useappcompat-v7 support library, you can omitPageIndicatorView dependencies by adding a single .aar file to your project, that will decrease total amount of methods used in your project.
implementation'com.romandanylyk:pageindicatorview:X.X.X@aar'Keep in mind, thatPageIndicatorView has minAPI level 14 and these dependencies:
implementation'com.android.support:appcompat-v7:27.1.1'implementation'com.android.support:recyclerview-v7:27.1.1'implementation'com.android.support:support-core-ui:27.1.1'
Usage ofPageIndicatorView is quite simple. All you need to do is to declare a view in yourlayout.xml and callsetSelection method to select specific indicator - that's it!
PageIndicatorViewpageIndicatorView =findViewById(R.id.pageIndicatorView);pageIndicatorView.setCount(5);// specify total count of indicatorspageIndicatorView.setSelection(2);
But if you're as lazy as I'm - then there is another option to handlePageIndicatorView
<com.rd.PageIndicatorViewandroid:id="@+id/pageIndicatorView"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"app:piv_animationType="scale"app:piv_dynamicCount="true"app:piv_interactiveAnimation="true"app:piv_selectedColor="@color/gray_50"app:piv_unselectedColor="@color/gray_300"app:piv_viewPager="@id/viewPager"attrs:piv_padding="12dp"attrs:piv_radius="8dp" />
All thepiv_ attributes here are specific forPageIndicatorView so you can customise it as you want with attributes - pretty handy.
But what is more important here isapp:piv_viewPager="@id/viewPager".What it actually do is catch up yourViewPager and automatically handles all the event's to selected the right page - so you don't need to callsetSelection method on your own.
Another handy options here that works with yourViewPager as a whole isapp:piv_dynamicCount="true" and app:piv_interactiveAnimation="true"
Dynamic count will automatically updatesPageIndicatorView total count as you updates pages count in yourViewPager - so that's pretty useful.
While interactive animation will progress the animation process within your swipe position, which makes animation more natural and responsive to end user.
Note: Because
setViewPagerIduses an instance ofViewPager, using it in recycler could lead to id conflicts, soPageIndicatorViewwill not know properly what is the rightViewPagerto work with. Instead you should handle selected indicators on your own programatically.
pager.addOnPageChangeListener(newViewPager.OnPageChangeListener() {@OverridepublicvoidonPageScrolled(intposition,floatpositionOffset,intpositionOffsetPixels) {/*empty*/}@OverridepublicvoidonPageSelected(intposition) {pageIndicatorView.setSelection(position); }@OverridepublicvoidonPageScrollStateChanged(intstate) {/*empty*/} });
Here you can see all the animationsPageIndicatorView support.
See release notes ongithub releases orBintray release notes.
Copyright 2017 Roman DanylykLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.About
An page indicator for Android ViewPager
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors12
Uh oh!
There was an error while loading.Please reload this page.









