Bug 4028 - Cannot set View Background Color to White (or any value above 0x7fffffff)
Summary: Cannot set View Background Color to White (or any value above 0x7fffffff)
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-03-22 10:30 UTC by Reto Senn
Modified: 2012-03-22 12:15 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Reto Senn 2012-03-22 10:30:24 UTC
If i try to set the background Color of a view with
SetBackgroundColor(0xffffffff), i get a compiler error as this is not a valid int value.
The same applies for new ColorDrawable(0xffffffff).

It works with SetBackgroundColor(-1) or new ColorDrawable(-1), but it is not the proper way to do so.

Setting the color to 0xffffff will create a transparent color as the alpha bits are not set.

Possible solution:
Change parameter type from int to uint.
Comment 1 Jonathan Pobst 2012-03-22 11:17:59 UTC
The recommended way of doing this is:

SetBackgroundColor (Color.White);
Comment 2 Reto Senn 2012-03-22 12:15:57 UTC
Thanks for the Info, this works. I see that the original method has the same structure.

I do have some remarks though:
- Color does have the same int constructor which has the same problems
- Adding a method like SetBackgroundColor(Color c) would make it a bit more obvious
- Help currently reads "Sets the background color for this view". Adding some hint to use Color would also be helpful :-)

Anyway, thanks for the quick help, much appreciated. You can close this ticket.