Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xamarin set view background color from a hex value

How do i programatically set the background color of a view using xamarin from the hex value

For example

 view.BackgroundColor = Color.FromHex("#00162E");
like image 367
CBaker Avatar asked Apr 16 '15 19:04

CBaker


1 Answers

I believe you're looking for the ParseColor method that takes in a string and returns the integer color.

view.BackgroundColor = Android.Graphics.Color.ParseColor("#FF6A00");

Supported formats are:

  • #RRGGBB
  • #AARRGGBB
  • 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray'
like image 109
ripple182 Avatar answered Oct 06 '22 03:10

ripple182