Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Xamarin中设置日期选择器对话框的颜色?_Xamarin_Datepicker_Xamarin.android_Xamarin.forms - Fatal编程技术网

如何在Xamarin中设置日期选择器对话框的颜色?

如何在Xamarin中设置日期选择器对话框的颜色?,xamarin,datepicker,xamarin.android,xamarin.forms,Xamarin,Datepicker,Xamarin.android,Xamarin.forms,我想知道如何更改点击日期或时间选择器时显示的对话框的背景和文本颜色。这是一个Xamarin表单项目,特别是android应用程序。这些属性不会暴露在DatePicker控件或我可以找到的渲染器中的任何位置。。。目前它显示为这个明亮的粉红色。。。谢谢 在您的style.xml中添加项目:“android:datePickerDialogTheme” <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyl

我想知道如何更改点击日期或时间选择器时显示的对话框的背景和文本颜色。这是一个Xamarin表单项目,特别是android应用程序。这些属性不会暴露在DatePicker控件或我可以找到的渲染器中的任何位置。。。目前它显示为这个明亮的粉红色。。。谢谢

在您的style.xml中添加项目:“android:datePickerDialogTheme”

<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>

<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
        <item name="colorAccent">#2196F3</item>
    </style>
@style/AppCompatDialogStyle
#2196F3
Complete style.xml

    <?xml version="1.0" encoding="UTF-8"?>
<resources>
    <style name="MyTheme" parent="MyTheme.Base">
    </style>
    <!-- Base theme applied no matter what API -->
    <style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
        <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
        <item name="windowNoTitle">true</item>
        <!--We will be using the toolbar so no need to show ActionBar-->
        <item name="windowActionBar">false</item>
        <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
        <!-- colorPrimary is used for the default action bar background -->
        <item name="colorPrimary">#2196F3</item>
        <!-- colorPrimaryDark is used for the status bar -->
        <item name="colorPrimaryDark">#2196F3</item>
        <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
        <item name="colorAccent">#2196F3</item>
        <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
        <item name="windowActionModeOverlay">true</item>
        <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
    </style>
    <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
        <item name="colorAccent">#2196F3</item>
    </style>
    <style name="MyDatePickerStyle" parent="@android:style/Widget.Material.Light.DatePicker">
        <item name="android:headerBackground">#2196F3</item>
    </style>
    <style name="MyDatePickerDialogTheme" parent="android:Theme.Material.Light.Dialog">
        <item name="android:datePickerStyle">@style/MyDatePickerStyle</item>
    </style>
</resources>

真的
假的
#2196F3
#2196F3
#2196F3
真的
@样式/应用程序对话框样式
#2196F3
#2196F3
@样式/MyDatePickerStyle

谢谢您的回复!进一步来看,我在app.xaml文件中为ios和android定义了样式,然后在xamarin表单控件上,我将样式定义为我想要的app.xaml样式。只是将上面的xml放到我的style.xml文件中并没有改变颜色,有没有一种方法可以同时使用app.xaml文件和style.xml?如何告诉控件使用适当的样式?