尝试解决我在 Android 和 iOS 上在深色模式下看到的问题,其中单选按钮的边框不显示。按下按钮后,将显示已选中的选项的实心圆圈,但我需要两个未选中的单选按钮圆圈都在那里,以便用户知道按钮在那里。有人知道如何让单选按钮格式在黑暗模式下正常工作吗?
这是按钮的 xaml:
<RadioButton x:Name="MyRadio0No" Grid.Row="0" Grid.Column="1" Content="No" BackgroundColor="White" BorderColor="{StaticResource AppMainColor}" FontSize="Body" TextColor="{StaticResource AppMainColor}" IsChecked="false" CheckedChanged="OnRadioButton0CheckedChanged" />
<RadioButton x:Name="MyRadio0Yes" Grid.Row="0" Grid.Column="2" Content="Yes" BackgroundColor="White" BorderColor="{StaticResource AppMainColor}" FontSize="Body" TextColor="{StaticResource AppMainColor}" IsChecked="false" HorizontalOptions="EndAndExpand" CheckedChanged="OnRadioButton0CheckedChanged"/>
灯光模式下的结果:
深色模式的结果:
我还尝试在 Styles.xaml 中设置边框颜色以及将其指定为深色模式,但这并没有改变任何内容:
<Style TargetType="RadioButton">
<Setter Property="BorderColor" Value="{AppThemeBinding Light={StaticResource AppMainColor}, Dark={StaticResource AppMainColor}}" />
...
</Style>
我在我这边做了测试,我这边可以重现这个问题。我们应该避免使用接近或与背景相同的颜色,否则我们会遇到你提到的问题。
所以,如果我删除代码
BackgroundColor="White"
,这个问题在黑暗模式下就不会再出现。
我的测试代码如下:
<RadioButton x:Name="MyRadio0No" Content="No" FontSize="Body" TextColor="Black" IsChecked="false"/>