Android TimePickerDialog material color

I use the timing dialog in my application. I also use appcompat to give an application design theme. The dialog, however, remains with the default color accent (my accent is blue).

so in my code I tried to set up the dialog theme myself, and it works, recognizing that it makes it fullscreen.

mTimePicker = new TimePickerDialog(ctx, R.style.AppTheme new TimePickerDialog.OnTimeSetListener() {->}, hour, minute, DateFormat.is24HourFormat(context)); 

Does anyone know how to set TimePickerDialog to correctly display my colors instead of the standard ones?

+7
android material-design android-timepicker
source share
1 answer

This can be easily obtained from xml (only 5.0+)

v21/themes.xml

 <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="Theme" parent="MyTheme.Base"> <item name="android:dialogTheme">@style/Theme.Dialog</item> <!-- TimePicker dialog --> <item name="android:alertDialogTheme">@style/Theme.Dialog</item> <!-- Alert dialog --> </style> <style name="Theme.Dialog" parent="android:Theme.Material.Light.Dialog"> <item name="android:colorAccent">@color/...</item> <item name="android:colorPrimary">@color/...</item> <item name="android:colorPrimaryDark">@color/...</item> </style> </resources> 

Edit
Please note that with Android Support Library 22.1.0 there is a new AppCompatDialog available! http://android-developers.blogspot.de/2015/04/android-support-library-221.html

+15
source share

All Articles