1/ Create A New Project . and use this Library
implementation 'com.github.denzcoskun:ImageSlideshow:0.1.2'
2/ Manifest Permission
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
3/ Open Settings.Gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // use this line
}
}
4/ 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"
tools:context=".MainActivity">
<androidx.cardview.widget.CardView
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="@dimen/_100sdp"
android:layout_margin="@dimen/_15sdp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="@dimen/_10sdp"
app:cardElevation="@dimen/_10sdp">
<com.denzcoskun.imageslider.ImageSlider
android:id="@+id/imageslider"
android:layout_width="match_parent"
android:layout_height="@dimen/_100sdp"
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>
5/ 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("https://wallpaperaccess.com/full/4307862.jpg", ScaleTypes.FIT));
slideModels.add(new SlideModel("https://cdn.fstoppers.com/styles/full/s3/media/2020/12/21/nando-vertical-horizontal-11.jpg", ScaleTypes.FIT));
slideModels.add(new SlideModel("https://wallpapercave.com/wp/wp4566625.jpg", ScaleTypes.FIT));
imageslider.setImageList(slideModels, ScaleTypes.FIT);
}
}
6/Run A see the output
#Happy Coding
#Image Slider