/ Slider

An image slider for android that let you pick the image loader library

An image slider for android that let you pick the image loader library

Image Slider

An image slider for android that let you pick the image loader library that best suits your needs.

Image-SliderX

Usage

Create a simple slider with the following code:

activity_main.xml

<com.ouattararomuald.slider.ImageSlider
      android:id="@+id/image_slider"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
/>

MainActivity.kt

class MainActivity : AppCompatActivity() {
  
  companion object {
    private const val SLIDE_NUMBER = 10
  }

  private lateinit var imageSlider: ImageSlider
  private val imageUrls = arrayListOf(
    "http://i.imgur.com/CqmBjo5.jpg", 
    "http://i.imgur.com/zkaAooq.jpg", 
    "http://i.imgur.com/0gqnEaY.jpg"
  )

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    imageSlider = findViewById(R.id.image_slider)
    imageSlider.adapter = SliderAdapter(
      this,
      PicassoImageLoaderFactory(),
      imageUrls = imageUrls,
      descriptions = Data.generateDescriptions(imageUrls.size)
    )
  }
}

Slider comes with Picasso as dependency to load an Images. If you want to use another library,
all you need is to extends ImageLoader#Factory and pass your factory to SliderAdapter.

Animations

A slider needs animations between each transition. To create a transition, all you need is to implement ViewPager.PageTransformer and pass it to ImageSlider#pageTransformer:

class MainActivity : AppCompatActivity() {
  
  companion object {
    private const val SLIDE_NUMBER = 10
  }

  private lateinit var imageSlider: ImageSlider
  private val imageUrls = arrayListOf(
    "http://i.imgur.com/CqmBjo5.jpg", 
    "http://i.imgur.com/zkaAooq.jpg", 
    "http://i.imgur.com/0gqnEaY.jpg"
  )

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    imageSlider = findViewById(R.id.image_slider)
    imageSlider.adapter = SliderAdapter(
      this,
      PicassoImageLoaderFactory(),
      imageUrls = imageUrls,
      descriptions = Data.generateDescriptions(imageUrls.size)
    )
    imageSlider.pageTransformer = MyPageTransformer() // Custom Page Transformer
  }
}

Atributes

The attributes below are available for usage in your xml files:

Attributes Descriptions
autoRecoverAfterTouchEvent Determines whether or not the ImageSlider should recover after user touch event.
indicatorBackground Reference to a background to be applied to Slider's indicator.
initialSlideDelay Delay in milliseconds before the first slide change.
initWithAutoCycling Determines whether or not the ImageSlider should immediately starts its transitions.
sliderBackground Reference to a background to be applied to Slider.
slideTransitionInterval Time in milliseconds between successive slide changes.

Download

Download the latest AAR or grab via Gradle:

implementation 'com.ouattararomuald:slider:1.0.0'

or Maven:

<dependency>
  <groupId>com.ouattararomuald</groupId>
  <artifactId>slider</artifactId>
  <version>1.0.0</version>
</dependency>

Snapshots of the development version are available in Sonatype's snapshots repository.

GitHub