gpt4 book ai didi

xamarin - 如何在 Xamarin 中设置 DatePicker 对话框的颜色?

转载 作者:行者123 更新时间:2023-12-01 22:24:43 25 4
gpt4 key购买 nike

我试图弄清楚如何更改点击日期或时间选择器时显示的对话框的背景和文本颜色。这是一个 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.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>

关于xamarin - 如何在 Xamarin 中设置 DatePicker 对话框的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39902273/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com