VOOZH about

URL: https://www.geeksforgeeks.org/android/slider-date-picker-in-android/

⇱ Slider Date Picker in Android - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Slider Date Picker in Android

Last Updated : 27 Sep, 2025

Slider Date Picker is one of the most popular features that we see in most apps. We can get to see this Slider date picker in most of the travel planning applications, Ticket booking services, and many more. Using Slider date Picker makes it efficient to pick the date. In this article, we are going to see how to implement Slider Date Picker in Android. A sample GIF is given below to get an idea about what we are going to do in this article. Note that we are going to implement this project using the Java language. 


Applications of Slider Date Picker

  • The most common application of this Slider date picker is it is used in most travel planning apps.
  • This Date Picker can also be seen in Ticket Booking services.
  • You can get to see this Slider Date Picker in the exam form filling application.

Attributes of Slider Date Picker

Attributes

Description

.setStartDate()To set the starting Date of the Calendar.
.setEndDate()To set the ending Date of the Calendar.
.setThemeColor()To set the theme Color.
.setHeaderTextColor()To set the header text Color.
.setHeaderDateFormat()To set the Date Format.
.setShowYear()To show the current year.
.setCancelText()To cancel text.
.setConfirmText()To confirm text.
.setPreselectedDate()To select today's date.

Step by Step Implementation

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.

Step 2: Add dependency and JitPack Repository

Navigate to the Gradle Scripts > build.gradle(Module:app) and add the below dependency in the dependencies section.   

implementation 'com.github.niwattep:material-slide-date-picker:v2.0.0'

Add the JitPack repository to your build file. Add it to your root build.gradle at the end of repositories inside the allprojects{ } section.

allprojects {

 repositories {

   ...

   maven { url "https://jitpack.io/" }

     }

}

After adding this dependency sync your project and now we will move towards its implementation.  

Step 3: Create a new Slider Date Picker in your activity_main.xml file

Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file. 

Step 4: Working with theMainActivity.java file

Go to the MainActivity.java file and refer to the following code. Below is the code for the MainActivity.java file. Comments are added inside the code to understand the code in more detail.

Now click on the run option it will take some time to build Gradle. After that, you will get output on your device as given below.

Output:

Comment

Explore