Indicator ViewPager is a library that allows you to create a indicator of viewpager with 3 style.
Add this in your root build.gradle
file (not your module build.gradle
file):
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add this to your module's build.gradle
file:
dependencies {
compile 'com.github.ATHBK:IndicatorView:v1.2.1'
}
To use this IndicatorView in your layout simply copy and paste the xml below. This provides the default indicator.
<com.athbk.indicatorview.IndicatorView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="30dp"
android:id="@+id/indicator"
app:indi_color_selected="#ffffff"
app:indi_color_unselected="#40ffffff"/>
There are several other attributes that can be used to configure color selected and unselected of indicator.
....
app:indi_color_selected="#ffffff"
app:indi_color_unselected="#40ffffff"
How to use in .
ViewPagerAdapter adapter = new ViewPagerAdapter(6);
viewPager.setAdapter(adapter);
indicator.setType(StyleIndicator.CIRCLE_STYLE_2);
indicator.setViewPager(viewPager);
** Note: You must declare type first, then setViewPager.
** 3 style in class StyleIndicator.
- StyleIndicator.CIRCLE_STYLE_1
- StyleIndicator.CIRCLE_STYLE_2
- StyleIndicator.SHAPE
** Update v1.1.1: change size of type shape
indicator.setType(StyleIndicator.SHAPE);
indicator.setHeightShape(16);
indicator.setWidthShape(50);
indicator.setViewPager(viewPager);
Copyright 2017 ATHBK
Licensed 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.0
Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.