微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Xamarin.Forms 图形问题 - DatePicker 文本丢失,切换背景丢失

如何解决Xamarin.Forms 图形问题 - DatePicker 文本丢失,切换背景丢失

我正在创建 Xamarin.Forms 应用程序(Android 和 iOS),但在使用 DatePickerSwitch 和其他控件时遇到图形问题。

enter image description here

我尝试在多个 Android 设备上构建新的示例应用程序(Visual Studio 随附),但问题仍然存在。 不过我在 Andorid 模拟器上没有遇到这个问题。

任何帮助表示赞赏。谢谢

解决方法

这是因为设备的主题。 (暗光)。您可以通过将这些添加到 style.xml

来覆盖颜色
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MainTheme" parent="MainTheme.Base">
    </style>
    <!-- Base theme applied no matter what API -->
    <style name="MainTheme.Base" parent="Theme.AppCompat.DayNight">
        <!--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 https://aka.ms/material-colors -->
        <!-- colorPrimary is used for the default action bar background -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <!-- colorPrimaryDark is used for the status bar -->
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
        <item name="colorAccent">@color/colorAccent</item>
        <!-- You can also set colorControlNormal,colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
        <item name="windowActionModeOverlay">true</item>
        <item name="android:statusBarColor">#000000</item>
        <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
    </style>
    <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
        <item name="colorAccent">@color/colorAccent</item>
    </style>
</resources>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。