Giter VIP home page Giter VIP logo

auto-image-slider's Introduction

Auto Image Slider

Screenshot

Image Slider Default Image Slider With Custom Adapter

Usage

  • Add ImageSlider to your layout
    <com.afdhal_fa.imageslider.ImageSlider
        android:id="@+id/imageSlide"
        android:layout_width="match_parent"
        android:layout_height="250dp"
        app:iss_auto_cycle="true"
        app:iss_delay="0"
        app:iss_period="1000"/>
  • You can change placeholder image.
 app:iss_placeholder="@drawable/placeholder"
  • You can change error image.
 app:iss_error_image="@drawable/error"
  • You can change image scale type.
 app:iss_image_scaleType="centerCrop"
  • You can change title color
app:iss_title_color="@color/purple_500"
  • You can hide title
app:iss_with_title="false"
  • You can hide background title
app:iss_with_background="false"
  • You can change text gravity
app:iss_title_gravity="center"
  • You can change text title background
app:iss_title_background="@drawable/gradient"
  • Add ImageSlider to your Activity
  val imageList = ArrayList<SlideUIModel>() 
  imageList.add(SlideUIModel("https://s.id/Ccoeo", "Blackpink - Jennie"))
  imageList.add(SlideUIModel("https://s.id/CcouZ", "Blackpink - Lisa"))
  imageList.add(SlideUIModel("https://s.id/CcoQ1", "Blackpink - Rose"))
  imageList.add(SlideUIModel("https://s.id/Cco-g", "Blackpink - Jisoo"))

  imageSlide.setImageList(imageList)
  • You can use click listener.
  imageSlide.setItemClickListener(object : ItemClickListener {
      override fun onItemClick(model: SlideUIModel, position: Int) {
          Toast.makeText(this@MainActivity, "${model.title}", Toast.LENGTH_SHORT).show()
      }
  })
  • You can add stop and start auto sliding again.
  imageSlide.startSliding(3000) // with new period
  imageSlide.startSliding()
  imageSlide.stopSliding()
  • You can make custom item slide with recyclerview adapter. You can see example adapter here Example Custom Adapter
  val imageList = ArrayList<BannerUIModel>() // Create image list
  imageList.add(BannerUIModel("https://s.id/Ccoeo", "Blackpink - Jennie"))
  imageList.add(BannerUIModel("https://s.id/CcouZ", "Blackpink - Lisa"))
  imageList.add(BannerUIModel("https://s.id/CcoQ1", "Blackpink - Rose"))
  imageList.add(BannerUIModel("https://s.id/Cco-g", "Blackpink - Jisoo"))
  mAdapter.setItem(imageList)
  binding.imageSlide.setImageListWithAdapter(mAdapter, imageList.size)
  mAdapter.onItemClick = {  // user click listener adapter
      Toast.makeText(this, it.title, Toast.LENGTH_SHORT).show()
   }

Dependencies

Add maven jitpack.io and dependencies in build.gradle (Project) :

// build.gradle project
allprojects {
  repositories {
     ...
     maven { url 'https://jitpack.io' }
  }
}

// build.gradle app/module
dependencies {
    ...
     implementation 'com.github.Fuadafdhal:Auto-Image-Slider:1.0'
}

License

Copyright 2021 Muh Fuad Afdhal

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.

auto-image-slider's People

Contributors

fuadafdhal avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.