Skip to content
This repository has been archived by the owner on Jul 20, 2018. It is now read-only.
/ ImageCarouselView Public archive

Image carousel view for Android: infinite, auto-scroll and intractable

License

Notifications You must be signed in to change notification settings

f3401pal/ImageCarouselView

Repository files navigation

ImageCarouselView

Custom image carousel view for Android. Support featrures:

  • Infinite auto-scroll (ALWAYS in one direction)
  • Scrollable manually with auto-scroll
  • Auto-settle to the closest position on scrolling manually

demo

Note: The library does not provide ways for loading images from URL. You could use libraries like Glide (see the example), Picasso, Fresco or write your own.

Limitations

  • Only support horizontal scroll
  • Only support images from URL
  • Manual scroll does not work smoothly inside NestedScrollView

QuickStart

This is a example of using Glide as image loader. See the example app for more details.

  • Create a image loader class extend ImageLoader and implement loadImage
private class GlideImageLoader extends ImageLoader {
        @Override
        protected void loadImage(String url, final OnResourceReadyListener listener) {
            // your own image loading logic here
            Glide.with(ExampleActivity.this)
                    .load(Uri.parse(url).normalizeScheme()).asBitmap()
                    .into(new SimpleTarget<Bitmap>() {
                        @Override
                        public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                            // must call this when bitmap resource is ready
                            listener.onResourceReady(resource);
                        }
                    });
        }
}

PS: make sure to call onResourceReady when the image bitmap is ready

  • Add ImageCarouselView into your layout XML
<com.f3401pal.imagecarouselview.ImageCarouselView
        android:id="@+id/carouselView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />
  • Set the image URLs and a instance of your image loader in ImageCarouselView
ImageCarouselView carouselView = (ImageCarouselView) findViewById(R.id.carouselView);
carouselView.setImageUrls(URLs, new GlideImageLoader());

About

Image carousel view for Android: infinite, auto-scroll and intractable

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages