Issue
How do i programatically set the background color of a view using xamarin from the hex value
For example
view.BackgroundColor = Color.FromHex("#00162E");
Solution
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'
Answered By - ripple182
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.