'How do I change the color of the timepicker in my Android app?

As you can see from the image below, I'm using the time picker in my app.
I need to change the color but don't know how...
Thanks for the help.

enter image description here



Solution 1:[1]

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

v21/themes.xml

<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>

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

Solution 2:[2]

Try this code

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="TimePicker" parent="Theme.AppCompat.Light.Dialog">
        <item name="android:windowIsFloating">true</item>
        <item name="colorAccent">@color/primary</item>
        <item name="colorControlActivated">@color/secondary</item>
        <item name="android:colorPrimary">@color/primary</item>
        <item name="android:colorPrimaryDark">@color/primary</item>
        <item name="android:buttonBarNegativeButtonStyle">@style/DatePickerTheme.ButtonBarButtonStyle</item>
        <item name="android:buttonBarPositiveButtonStyle">@style/DatePickerTheme.ButtonBarButtonStyle</item>
    </style>

    <style name="DatePickerTheme.ButtonBarButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
        <item name="android:textColor">@color/primary</item>
    </style>
</resources>

The first one is colorAccent, the second is colorControlActivated and the last one does not belong to the timepicker, it belongs to dialog so you should apply the an style similar to this post

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 shinilms
Solution 2 blacktiago