我的主题/颜色设置...
应用程序.xaml:
<Application.Resources>
<Color x:Key="PageBackgroundColor">#1F1F1F</Color>
<Style TargetType="Entry">
<Setter Property="HorizontalOptions" Value="Fill" />
<Setter Property="TextColor" Value="Whitesmoke" />
<Setter Property="PlaceholderColor" Value="Red" />
<Setter Property="HorizontalTextAlignment" Value="Center" />
</Style>
<Style TargetType="Label">
<Setter Property="TextColor" Value="WhiteSmoke" />
</Style>
<Style TargetType="TimePicker">
<Setter Property="TextColor" Value="WhiteSmoke" />
</Style>
<Style TargetType="Picker">
<Setter Property="TextColor" Value="WhiteSmoke" />
<Setter Property="TitleColor" Value="Red" />
</Style>
</Application.Resources>
样式.xml:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
<item name="colorAccent">#ff0000</item>
</style>
<style name="MainTheme.Base" parent="Theme.AppCompat.Light">
<item name="android:timePickerDialogTheme">@style/MyTimePickerDialogStyle</item>
</style>
<style name="MyTimePickerDialogStyle" parent="@style/ThemeOverlay.AppCompat.Dialog.Alert">
<item name="colorControlActivated">#FF0000</item>
<item name="colorAccent">#000000</item>
<item name="android:textColorPrimary">#000000</item>
<item name="android:textColorSecondary">#000000</item>
</style>
</resources>
MainPage.xaml:
<ContentPage ...
BackgroundColor="{DynamicResource PageBackgroundColor}"
...>
...
<Button ... TextColor="#F5F5F5" BackgroundColor="#007F00" ... />
...
<Label ... BackgroundColor="#F5F5F5" ... />
无论选择何种深色/浅色模式,我的应用程序都应处于深色背景中。暗/亮模式不应影响任何颜色。Android 10 上的浅色模式没有颜色问题。使用深色模式:
- 按钮绿色 (#008000) 变成了石灰,这使得白色文本颜色不可读,所以我不得不将按钮背景颜色属性从绿色 (#008000) 更改为 #007F00,尽管两种颜色之间的差异很小,但效果出奇地好
- 标签 WhiteSmoke (#F5F5F5) 变暗
- 如果我将 更改
<Setter Property="TextColor" Value="WhiteSmoke" />
为<Setter Property="BackgroundColorColor" Value="WhiteSmoke" />
,则更改将仅适用于浅色主题 - 将 BackgroundColor 设置为 Red (#FF0000) 的按钮没有问题
为什么在地球上暗模式只影响某些颜色?我猜有一些设置可以覆盖暗模式。有什么建议么?
编辑:有没有办法停用暗模式?如何设置主题、样式、颜色等,使其不受暗/亮模式的影响?
EDIT2:截图...
灯光模式:
黑暗模式:
EDIT3:它也会影响图像。
我尝试了两张几乎相同的图像,唯一的区别是红色和绿色背景。背景的其余部分是透明的。“滑动”一词和箭头是#F5F5F5 颜色,而“A”周围的圆圈是#FFFFFF。这些图像是来自 Photoshop 的新鲜图像:
白色/深色模式下的屏幕截图:
如您所见,暗模式仅影响两个图像中的一个,类似于我之前提到的十六进制颜色。