【发布时间】:2021-10-01 15:27:57
【问题描述】:
DatePicker Dialog 我正在 Xamarin.Forms 中开发一个应用程序。我设法更改了 DatePicker 日历对话框的强调色,现在我可以将此颜色应用于“标题”区域,但我的问题是:如何更改正文背景颜色,以及如何更改字体颜色(数字颜色)?
【问题讨论】:
标签: xamarin.forms datepicker background-color
DatePicker Dialog 我正在 Xamarin.Forms 中开发一个应用程序。我设法更改了 DatePicker 日历对话框的强调色,现在我可以将此颜色应用于“标题”区域,但我的问题是:如何更改正文背景颜色,以及如何更改字体颜色(数字颜色)?
【问题讨论】:
标签: xamarin.forms datepicker background-color
picker是一个原生的平台控件,需要在各个平台项目中单独修改。
安卓:
<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>
对于 iOS,您可以使用如下所示的自定义渲染器。 How to change visual material DatePickerDialog and TimePickerDialog background color in xamarin forms
【讨论】: