Sunday, 4 April 2021

Configuring android date picker dialog for dark mode

I have a date picker dialog that I use in spinner mode. This is the theme used by the date picker dialog.

<style name="CustomDatePickerDialogTheme" parent="android:Theme.Material.Light.Dialog">
        <item name="android:datePickerStyle">@style/MyDatePickerStyle</item>
    </style>

    <style name="MyDatePickerStyle" parent="@android:style/Widget.Material.DatePicker">
        <item name="android:datePickerMode">spinner</item>

This works fine when I use it when "Dark Mode = off". But it does not reverse the colors when "Dark Mode = on". Irrespective of the Dark Mode this is how the dialog looks like

enter image description here

I tried changing the parent theme to Theme.AppCompat.DayNight.Dialog. Now the dialog looks like this when "Dark Mode = on"

enter image description here

How do I make the DatePickeDialog (in spinner mode) compatible with Dark Mode?



from Configuring android date picker dialog for dark mode

No comments:

Post a Comment