I was testing my app on an Android L emulator, and I noticed that the TimePickerDialog has significantly changed to this:
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.
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.
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.
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With