Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An page indicator for Android ViewPager

NotificationsYou must be signed in to change notification settings

romandanylyk/PageIndicatorView

Repository files navigation

DownloadAndroid Arsenal
API

PageIndicatorView is light library to indicate ViewPager's selected page with different animations and ability to customise it as you need.

Integration

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 havejcenter repository 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.

See latest library versionDownload

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 Sample

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: BecausesetViewPagerId uses an instance ofViewPager, using it in recycler could lead to id conflicts, soPageIndicatorView will not know properly what is the rightViewPager to 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.

NameSupport versionPreview
AnimationType.NONE0.0.1anim_none
AnimationType.COLOR0.0.1anim_color
AnimationType.SCALE0.0.1anim_scale
AnimationType.SLIDE0.0.1anim_slide
AnimationType.WORM0.0.1anim_worm
AnimationType.FILL0.0.6anim_worm
AnimationType.THIN_WORM0.0.7anim_thin_worm
AnimationType.DROP0.1.0anim_drop
AnimationType.SWAP0.1.1anim_swap

Release Note

See release notes ongithub releases orBintray release notes.

License

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

Stars

Watchers

Forks

Packages

No packages published

Contributors12

Languages


[8]ページ先頭

©2009-2026 Movatter.jp