VOOZH about

URL: https://www.geeksforgeeks.org/android/implement-customized-timepicker-in-android-using-snaptimepicker/

⇱ Implement customized TimePicker in Android using SnapTimePicker - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Implement customized TimePicker in Android using SnapTimePicker

Last Updated : 15 Jul, 2025

Android TimePicker is a user interface control for selecting the time in either 24-hour format or AM/PM mode. It is used to ensure that users pick a valid time for the day in the application. The default TimePicker can be customized by using the SnapTimePicker in Android.

Features of SnapTimePicker

Some key features provided by SnapTimePicker are mentioned below:

  • Selectable time range support.
  • Text and color customization.
  • IOS Time Picker like with Material Design style.
👁 snap-time-picker


Step by Step Implementation

Step 1: Add necessary dependencies

Add the support Library in build.gradle.kts file and add dependency in the dependencies section.

implementation ("com.akexorcist:snap-time-picker:1.0.3")

Step 2: Update string.xml file

Add the following code in string.xml file in values directory. In this file add all string used in the app. These string can be referenced from app or some other resource files(such as XML layout).

string.xml:


Step 3: Working with activity_main.xml file

Add the following code in activity_main.xml file. In this file add the Buttons to select the time and the TextView to display the selected time.

activity_main.xml:

Design UI:

👁 Layout


Step 4: Working with MainActivity.kt

Add the following code in MainActivity.kt file. In this file add onClickListener() method to the buttons so that whenever user click on them a TimePicker dialog will be created.

MainActivity.kt:

Output:

Advantages:

The advantages of using SnapTimePicker over simple TimePicker are:

  1. SnapTimePicker can be customized according to the requirements.
  2. It is very easy to use.
  3. It gives IOS feel of an app.
Comment
Article Tags:

Explore