Skip to content

Instantly share code, notes, and snippets.

@baileysh9
Last active July 19, 2018 20:53
Show Gist options
  • Save baileysh9/10bf101ee6132d88ba2776d2d56f71ca to your computer and use it in GitHub Desktop.
Save baileysh9/10bf101ee6132d88ba2776d2d56f71ca to your computer and use it in GitHub Desktop.
Android implementation of the Gradient View Render
public void CreateGradient()
{
//Need to convert the colors to Android Color objects
int[] androidColors = new int[gradientColors.Count()];
for (int i = 0; i < gradientColors.Count(); i++)
{
Xamarin.Forms.Color temp = gradientColors[i];
androidColors[i] = temp.ToAndroid();
}
GradientDrawable gradient = new GradientDrawable(GradientDrawable.Orientation.LeftRight, androidColors);
if (roundCorners)
gradient.SetCornerRadii(new float[] { cornerRadius, cornerRadius, cornerRadius, cornerRadius, cornerRadius, cornerRadius, cornerRadius, cornerRadius });
layout.SetBackground(gradient);
}
@adhamali450
Copy link

what is this layout variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment