【问题标题】:What is the default background color of any Page in Xamarin Forms Android?Xamarin Forms Android 中任何页面的默认背景颜色是什么?
【发布时间】:2021-07-07 15:32:48
【问题描述】:

在未应用任何自定义主题或样式的情况下,Xamarin Forms Android 应用在浅色模式下的默认背景颜色是什么?我想放置一个与背景颜色相同的按钮。背景颜色不是白色,当我将按钮放置为白色时,按钮的颜色与背景不同。

我知道我可以将页面和按钮的颜色都设置为白色或其他任何颜色,但我想使用 Xamarin Forms Android 提供的相同默认背景颜色。

<StackLayout>
    <Button Text="Button" BackgroundColor="White" />
</StackLayout>

在输出中,您可以看到按钮的白色与背景颜色略有不同。

这是输出

【问题讨论】:

    标签: c# xaml xamarin xamarin.forms


    【解决方案1】:

    您可以通过引用在android项目中获取主题的默认背景颜色:

    ?android:colorBackground
    

    比如你可以打开Resources/values/colors,任意定义一个颜色值

    <color name="defaultcolor">?android:colorBackground</color>
    

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

    #fffafafa
    

    【讨论】:

      猜你喜欢
      • 2011-12-24
      • 1970-01-01
      • 2019-02-09
      • 2011-06-07
      • 1970-01-01
      • 2013-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多