Created
November 30, 2017 22:26
-
-
Save rdelrosario/7d4ae998afe429363c041efee0bd9d56 to your computer and use it in GitHub Desktop.
Android - Create Shape
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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