public void SetCornerRadiusWithColor (Color backgroundColor, float[] arr) { GradientDrawable background = new GradientDrawable (); background.SetCornerRadii (arr); background.SetColor (backgroundColor); Background = background; }
GradientDrawable CreateBackgroundDrawable(CornerSide setCornerSide, Android.Graphics.Color backgroundColor, float cornerRadius) { var gDrawable = new GradientDrawable(); float[] corners; //Set X and Y for each corner //The corners are ordered top-left, top-right, bottom-right, bottom-left switch (setCornerSide) { case CornerSide.LeftSide: corners = new float[]{ cornerRadius, cornerRadius, DefaultCorner, DefaultCorner, DefaultCorner, DefaultCorner, cornerRadius, cornerRadius }; break; case CornerSide.RightSide: corners = new float[]{ DefaultCorner, DefaultCorner, cornerRadius, cornerRadius, cornerRadius, cornerRadius, DefaultCorner, DefaultCorner }; break; default : corners = new float[]{ DefaultCorner, DefaultCorner, DefaultCorner, DefaultCorner, DefaultCorner, DefaultCorner, DefaultCorner, DefaultCorner }; break; } gDrawable.SetCornerRadii(corners); gDrawable.SetColor(backgroundColor.ToArgb()); return gDrawable; }