Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change the style of an Android L TimePickerDialog?

Tags:

I was testing my app on an Android L emulator, and I noticed that the TimePickerDialog has significantly changed to this:

Android L TimePickerDialog

This doesn't fit with the theme of my app, and I wanted to know if it is possible to get the old TimePickerDialog style when running on Android L.

like image 489
JDJ Avatar asked Jun 27 '14 10:06

JDJ


People also ask

How do I change the color of my time picker dialog?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. Kindly fine the highlighted code, this is the simplest way to change the colour of your datePicker.

What is TimePicker dialog in android?

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 the valid time for the day in our application. The time picker interface exists basically in two modes one is under XML layout and another is a dialog.


2 Answers

Add android:timePickerMode="spinner" to the XML

    <TimePicker
        android:id="@+id/timePicker1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:timePickerMode="spinner">
    </TimePicker>

https://developer.android.com/reference/android/R.attr.html#timePickerMode

You can choose between spinner or clock modes. This attribute is only available from API level 21, before that the spinner mode was the only option available.

like image 65
yehyatt Avatar answered Oct 03 '22 21:10

yehyatt


You can use the TimePickerDialog constructor with theme parameter to specify the theme.

TimePickerDialog(Context context, 
                 int theme, 
                 TimePickerDialog.OnTimeSetListener callBack, 
                 int hourOfDay, 
                 int minute, 
                 boolean is24HourView)
like image 42
LordRaydenMK Avatar answered Oct 03 '22 20:10

LordRaydenMK