1/ Create A New Project . and use this Library
implementation 'com.github.denzcoskun:ImageSlideshow:0.1.2'
2/ Open Settings.Gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // use this line
}
}
3/ Open Activity XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<androidx.cardview.widget.CardView
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="220dp"
android:layout_margin="10dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="10dp"
app:cardElevation="10dp">
<com.denzcoskun.imageslider.ImageSlider
android:id="@+id/imageslider"
android:layout_width="match_parent"
android:layout_height="220dp"
app:iss_auto_cycle="true"
app:iss_corner_radius="10"
app:iss_delay="1000"
app:iss_period="1000"
app:iss_selected_dot="@drawable/default_selected_dot" />
</androidx.cardview.widget.CardView>
</LinearLayout>
4/ Open Java Activity
package com.example.imageslider;
import android.os.Bundle;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.denzcoskun.imageslider.ImageSlider;
import com.denzcoskun.imageslider.constants.ScaleTypes;
import com.denzcoskun.imageslider.models.SlideModel;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
ImageSlider imageslider;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageslider= findViewById(R.id.imageslider);
//slide
ArrayList<SlideModel> slideModels = new ArrayList<>();
slideModels.add(new SlideModel(R.drawable.img1, ScaleTypes.FIT));
slideModels.add(new SlideModel(R.drawable.img2, ScaleTypes.FIT));
slideModels.add(new SlideModel(R.drawable.img3, ScaleTypes.FIT));
imageslider.setImageList(slideModels, ScaleTypes.FIT);
}
}
5/Run A see the output
#Happy Coding
#Image Slider