1

DatePicker Dialog I'm developing an app in Xamarin.Forms. I managed to change the accent color of the DatePicker calendar dialog, and now I'm able to apply this color to the "Header" area, but my question is: How can I change the body background color, and also how can I change the font color (numbers color)?

1 Answer 1

1

The picker is a native platform control, so you need to modify if separately in each platform project.

Android:

<style name="MainTheme" parent="MainTheme.Base">
<!-- As of Xamarin.Forms 4.6 the theme has moved into the Forms binary -->
<!-- If you want to override anything you can do that here. -->
<!-- Underneath are a couple of entries to get you started. -->

<!-- Set theme colors from https://aka.ms/material-colors -->
<!-- colorPrimary is used for the default action bar background -->
<!--<item name="colorPrimary">#2196F3</item>-->
<!-- colorPrimaryDark is used for the status bar -->
<!--<item name="colorPrimaryDark">#1976D2</item>-->
<!-- colorAccent is used as the default value for colorControlActivated
     which is used to tint widgets -->
<!--<item name="colorAccent">#FF4081</item>-->
<item name="android:datePickerDialogTheme">@style/PickerDialogStyle</item>
</style>

<style name="PickerDialogStyle" parent="Theme.AppCompat.Light.Dialog">
 //header color
 <item name="colorAccent">#039BE5</item>
 <item name="android:layout_width">wrap_content</item>
 <item name="android:layout_height">wrap_content</item>
 //number color
 <item name="android:textColorPrimary">#ff0000</item>
 //body color
 <item name="android:windowBackground">@android:color/darker_gray</item>
 //all the dialog color
 <!--<item name="android:background">@android:color/darker_gray</item>-->
 </style>

enter image description here

For iOS, you could use the custom renderer like below. How to change visual material DatePickerDialog and TimePickerDialog background color in xamarin forms

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much. Now this would solve my problem as there is a bug in Dark mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.