How to make a good image slider in android studio (Image slider)

 


Setup

Paste this in setting.gradle

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


paste this in build.gradle dependencies

dependencies {
	implementation 'com.github.denzcoskun:ImageSlideshow:0.1.2'
}

Use this code in xml to adjust all the images

<com.denzcoskun.imageslider.ImageSlider    
     android:id="@+id/image_slider"    
     android:layout_width="wrap_content"    
     android:layout_height="300dp"    
     app:iss_auto_cycle="true"    
     app:iss_period="1000"    
     app:iss_delay="1000"    
     app:iss_text_align="CENTER"/>  


Add images to imageslide in activity use below code 

val imageList = ArrayList<SlideModel>() // Create image list  
  
// imageList.add(SlideModel("String Url" or R.drawable)  
// imageList.add(SlideModel("String Url" or R.drawable, "title") You can add title  
  
imageList.add(SlideModel("https://bit.ly/2YoJ77H", "The animal population decreased by 58 percent in 42 years."))  
imageList.add(SlideModel("https://bit.ly/2BteuF2", "Elephants and tigers may become extinct."))  
imageList.add(SlideModel("https://bit.ly/3fLJf72", "And people do that."))  
  
val imageSlider = findViewById<ImageSlider>(R.id.image_slider)  
imageSlider.setImageList(imageList)  



GitHub Link : https://github.com/denzcoskun/ImageSlideshow

Comments

Popular posts from this blog

Android Auto Transition