1、依赖包:
compile 'com.romandanylyk:pageindicatorview:X.X.X'
If your project already use appcompat-v7
support library, you can omit PageIndicatorView
dependencies by adding a single .aar file to your project, that will decrease total amount of methods used in your project.
compile 'com.romandanylyk:pageindicatorview:X.X.X@aar'
Keep in mind, that PageIndicatorView
has min API level 14 and these dependencies:
compile 'com.android.support:support-annotations:25.3.0'
compile 'com.android.support:support-compat:25.3.0'
compile 'com.android.support:support-core-ui:25.3.0'
ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); viewPager.setAdapter(adapter); //instance of android.support.v4.view.PagerAdapter adapter PageIndicatorView pageIndicatorView = (PageIndicatorView) view.findViewById(R.id.pageIndicatorView); pageIndicatorView.setViewPager(viewPager);
3、布局中
<com.rd.PageIndicatorView android:id="@+id/pageIndicatorView" android:layout_width="wrap_content" android:layout_height="wrap_content" attrs:piv_viewPager="@+id/viewPager"/>

github地址:https://github.com/romandanylyk/PageIndicatorView