Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default background color of any Page in Xamarin Forms Android?

What is the default background color in Xamarin Forms Android App in the light mode without applying any custom theme or style? I want to place a button that has the same color as that of the background. The Background color is not White, as when I place Button with White color, the Button's color is different from the background.

I know I can set both Page's and Button's color as White or anything else, but I want to use the same default background color that's provided by Xamarin Forms Android.

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

In the output, you can see the white color of the button is slightly different from that of the background.

Here is the output

enter image description here

like image 802
Junaid Pathan Avatar asked Oct 19 '25 10:10

Junaid Pathan


1 Answers

You can get your theme's default background color in android project by referencing:

?android:colorBackground

For example,you could open the Resources/values/colors,and arbitrarily define a color value

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

And then you can see that its color value is

#fffafafa
like image 194
Leo Zhu - MSFT Avatar answered Oct 21 '25 00:10

Leo Zhu - MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!