Reputation: 31
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)?
Upvotes: 1
Views: 422
Reputation: 10958
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>
For iOS, you could use the custom renderer like below. How to change visual material DatePickerDialog and TimePickerDialog background color in xamarin forms
Upvotes: 1