Xamarin Forms Android应用在亮色模式下,如果没有应用自定义主题或样式,其默认背景颜色是什么?我想放置一个按钮,其颜色与背景颜色相同。背景颜色不是白色,因为当我放置白色按钮时,按钮的颜色与背景不同。我知道我可以将页面和按钮的颜色都设置为白色或其他任何颜色,但我想使用由Xamarin Forms Android提供的相同默认背景颜色。<StackLayout> <Button Text="Button" BackgroundColor="White" /> </StackLayout> 在输出中,您可以看到按钮的白色与背景的白色略有不同。以下是输出结果:
您可以通过引用以下内容,在 Android 项目中获取主题的默认背景颜色: ?android:colorBackground 例如,您可以打开资源/值/颜色文件,随意定义一个颜色值。<color name="defaultcolor">?android:colorBackground</color> 然后你可以看到它的颜色值为 #fffafafa