TimePicker is UI (User Interface) Element in android That allows user to select a time. 
It allows you to select time by Hours and Minute and TimePicker is a subclass of FrameLayout Class. To Create TimePicker In Android We Use <TimePicker> Tag in XML And You can also create TimePicker Programmatically.

Table of Contents

Important TimePicker Attributes

Attribute Description
android:timePickerMode
You can set this attribute either spinner or clock

If you set timePickerMode=”clock”
Your TimePicker will look like this

TimePicker in Android clock mode

If you set timePickerMode=”spinner”
Your TimePicker will look like this

TimePicker in Android spinner mode

If you want to create TimePicker in clock mode, Then In your XML file Inside your <TimePicker> Tag You can set android:timePickerMode to Clock or you can set this attribute to spinner in order to use TimePicker in spinner mode. According to your need you can use both this mode inside your app. Now Let’s Understand it with an example.

Important TimePicker Methods

Attribute Description
is24HourView()
This method returns true if the TimePicker is in 24 hours View
getCurrentHour()
To get Selected Hour
getCurrentMinute()
To Get the Selected Minute
setIs24HoursView()
If it’s true TimePicker will be in 24 Hours View
setCurrentHour(Integer currentHour)
This method sets the current hour
setCurrentMinute(Integer currentMinute)
This method sets the current minute

TimePicker Example

Here is an example Demonstrating How to Use TimePicker. 

File : activity_main.xml


Activity Class 
File : MainActivity.java

If you find this content Helpful feel free to Enroll in our Android Development Course with Kotlin contact us for more information 

If you liked this article, then share it with your friends.

Related Tutorials

Anatomy of an android app
Anatomy of an Android App
  • July 18, 2025
  • Com 0

Anatomy of an Android App Anatomy of an Android app refers to its core structure and essential components that work…

Roomdatabase in android image
Mastering room database using kotlin: Complete Guide with CRUD Operations
  • April 4, 2025
  • Com 0

Local data storage is essential for building modern Android apps that work offline and store data persistently. Whether you’re creating…

Android SDK Image
Android SDK and It’s Components
  • March 27, 2025
  • Com 0

Android SDK stands for Android Software Development Kit which is developed by Google for Android Platform with the help of…

Android Architecture Image
Android Architecture
  • March 20, 2025
  • Com 0

Android architecture is the foundation and structure that makes an Android device work. Android architecture consists of layers that work together to run apps…

Content Provider in Android Feature Image
Content Provider in Android
  • February 7, 2025
  • Com 0

Content Provider in Android is a component of the Android application that is useful for sharing data with other apps.…

SQLite Database in Android
SQLite Database in Android
  • January 28, 2025
  • Com 0

Android app or any application is made of two things Data And Functionality. So In Any application we need a…

Get Your Free Java
Data Structures Cheat Sheet! 🎁

Download the ultimate cheat sheet covering the Top 10 Data Structures every Java developer must know — with real-life examples! Just enter your email and get the free pdf.

We respect your privacy. No spam. Read our privacy policy for more information.