byte byte - 4 months ago 96
Android Question

How to change the style of Date picker in android?

I want to change the default color of the date or time picker dialog in android, so that it should match my app's theme. I searched for the same on google, but I couldn't find a valid solution.

What I was doing is, I was creating a new style .

<style name="datepicker" parent="@android:style/Widget.DeviceDefault.DatePicker">
<!---TODO-->
<item name="android:focusedMonthDateColor">@android:color/holo_red_dark</item>
</style>


Don't know what are the attributes available for date picker dialouge, that would be greta if anyone post a link on that

and after adding the style i was calling it in my main style as

<item name="android:datePickerStyle">@style/datepicker</item>


Unfortunately, this didn't work for me at all.

Answer

try this

    <style name="datepicker" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/primary</item>

</style>