Xamarin Forms Android中任何页面的默认背景颜色是什么?

4
Xamarin Forms Android应用在亮色模式下,如果没有应用自定义主题或样式,其默认背景颜色是什么?我想放置一个按钮,其颜色与背景颜色相同。背景颜色不是白色,因为当我放置白色按钮时,按钮的颜色与背景不同。我知道我可以将页面和按钮的颜色都设置为白色或其他任何颜色,但我想使用由Xamarin Forms Android提供的相同默认背景颜色。
<StackLayout>
    <Button Text="Button" BackgroundColor="White" />
</StackLayout>

在输出中,您可以看到按钮的白色与背景的白色略有不同。
以下是输出结果:

enter image description here

1个回答

3

您可以通过引用以下内容,在 Android 项目中获取主题的默认背景颜色:

?android:colorBackground

例如,您可以打开资源/值/颜色文件,随意定义一个颜色值。
<color name="defaultcolor">?android:colorBackground</color>

然后你可以看到它的颜色值为

#fffafafa

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接