Search code examples
xamarinxamarin.formsxamarin.android

How to change Xamarin DatePicker popup header and Background to White and also Font Color to Gray


I am trying to give custom look and feel to the datePicker popup. But I could not find any direct fields to change the header Background and Font Color of text shown in popup

enter image description here


Solution

  • You can try using below code inside styles.xml in Android Project.

        <resources>
    <style name="MainTheme" parent="MainTheme.Base">
        <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
    </style>
    <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
        <!--header background-->
        <item name="colorAccent">#fff</item>
        <!--header textcolor-->
        <item name="android:textColorPrimaryInverse">#808080</item>
        <!--body background-->
        <item name="android:windowBackground">#fff</item>
        <!--selected day-->
        <item name="android:colorControlActivated">#4B6043</item>
        <!--days of the month-->
        <item name="android:textColorPrimary">#808080</item>
        <!--days of the week-->
        <item name="android:textColorSecondary">#808080</item>
        <!--cancel&ok-->
        <item name="android:textColor">#808080</item>
    </style>
    

    Customized Xamarin Forms Date Picker