Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.classtingmobile:InfiniteIndicator:-SNAPSHOT'
}
dependencies {
implementation("com.github.classtingmobile:InfiniteIndicator:-SNAPSHOT")
}
<dependency>
<groupId>com.github.classtingmobile</groupId>
<artifactId>InfiniteIndicator</artifactId>
<version>-SNAPSHOT</version>
</dependency>
libraryDependencies += "com.github.classtingmobile" % "InfiniteIndicator" % "-SNAPSHOT"
:dependencies [[com.github.classtingmobile/InfiniteIndicator "-SNAPSHOT"]]
This project is inspired by the android-auto-scroll-view-pager of Trinea. Use the salvage lib implement view recycle adapter.It contains two style.One is CircleIndicator seperated from Android-ViewPagerIndicator.Another is copy from CircleIndicator.You can custome style and animation.
<a href="apk/demo.apk?raw=true" target="_blank" title="APK Download">APK Donwload</a>
setInterval(long)
set interval time of scroll in milliseconds, default is DEFAULT_INTERVAL
.setDirection(int)
set auto scroll direction, default is RIGHT
.setInfinite(boolean)
set whether infinite scroll when auto scroll reaching the last or first item, default is true.setScrollDurationFactor(double)
set the factor by which the duration of sliding animation will change.setStopScrollWhenTouch(boolean)
set whether stop auto scroll when touching, default is true.setIndicatorPosition
set present position of indicator.start()
start auto scroll, delay time is getInterval()
.start(int)
start auto scroll delayed.stop()
stop auto scroll.indicator_type
the style enum of Indicator
indicator_default
CirCleIndicatorindicator_anim_circle
AnimCircleIndicatorindicator_anim_line
is AnimLineIndicatorImageLoader
You can use any image loader library you what,there are several imageloader of Glide ,Picasso and UIL,decide how to load image,is absolutely free.
compile 'cn.lightsky.infiniteindicator:library:1.1.0'
<cn.lightsky.infiniteindicator.InfiniteIndicatorLayout
android:id="@+id/indicator_default_circle"
app:indicator_type="indicator_anim_circle"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
public class AnimIndicatorActivity extends FragmentActivity implements ViewPager.OnPageChangeListener,OnPageClickListener{
private ArrayList<Page> pageViews;
private InfiniteIndicator mAnimCircleIndicator;
private InfiniteIndicator mAnimLineIndicator;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_anim_indicator);
initData();
mAnimCircleIndicator = (InfiniteIndicator)findViewById(R.id.infinite_anim_circle);
mAnimCircleIndicator.setImageLoader(new UILoader());
mAnimCircleIndicator.addPages(pageViews);
mAnimCircleIndicator.setPosition(InfiniteIndicator.IndicatorPosition.Center);
mAnimCircleIndicator.setOnPageChangeListener(this);
}
private void initData() {
pageViews = new ArrayList<>();
pageViews.add(new Page("A ", "https://raw.githubusercontent.com/lightSky/InfiniteIndicator/master/res/a.jpg",this));
pageViews.add(new Page("B ", "https://raw.githubusercontent.com/lightSky/InfiniteIndicator/master/res/b.jpg",this));
pageViews.add(new Page("C ", "https://raw.githubusercontent.com/lightSky/InfiniteIndicator/master/res/c.jpg",this));
pageViews.add(new Page("D ", "https://raw.githubusercontent.com/lightSky/InfiniteIndicator/master/res/d.jpg",this));
}
//To avoid memory leak ,you should release the res
@Override
protected void onPause() {
super.onPause();
mAnimCircleIndicator.stop();
}
@Override
protected void onResume() {
super.onResume();
mAnimCircleIndicator.start();
}
@Override
public void onPageSelected(int position) {
//do something
}
@Override
public void onPageClick(int position, Page page) {
//do something
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
}
Thanks
android-auto-scroll-view-pager
AndroidImageSlider
CircleIndicator
Android-ViewPagerIndicator
About me
Weibo: light_sky
Blog: lightskystreet.com light_sky
Email: lightsky.cn@gmail.com