Skip to content

Instantly share code, notes, and snippets.

@rdelrosario
Created November 30, 2017 22:26
Show Gist options
  • Save rdelrosario/7d4ae998afe429363c041efee0bd9d56 to your computer and use it in GitHub Desktop.
Save rdelrosario/7d4ae998afe429363c041efee0bd9d56 to your computer and use it in GitHub Desktop.
Android - Create Shape
Drawable CreateShape(ShapeType type,int strokeWidth,int cornerRadius,Xamarin.Forms.Color? fillColor,Xamarin.Forms.Color? strokeColor)
{
GradientDrawable shape = new GradientDrawable();
shape.SetShape(type);
if(fillColor !=null)
{
shape.SetColor(fillColor?.ToAndroid() ?? Xamarin.Forms.Color.Transparent.ToAndroid());
}
if (strokeColor != null)
{
shape.SetStroke(strokeWidth, strokeColor?.ToAndroid()??Xamarin.Forms.Color.Transparent.ToAndroid());
}
shape.SetCornerRadius(cornerRadius);
return shape;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment