Skip to content

Instantly share code, notes, and snippets.

@lilac
Created July 27, 2015 23:53
Show Gist options
  • Save lilac/101aaf745fba988614c5 to your computer and use it in GitHub Desktop.
Save lilac/101aaf745fba988614c5 to your computer and use it in GitHub Desktop.
Create a rounded color drawable with a border
// This snippet is from http://stackoverflow.com/questions/17667964/how-to-create-shape-with-solid-corner-stroke-in-java-code
int strokeWidth = 5; // 3px not dp
int roundRadius = 15; // 8px not dp
int strokeColor = Color.parseColor("#2E3135");
int fillColor = Color.parseColor("#DFDFE0");
GradientDrawable gd = new GradientDrawable();
gd.setColor(fillColor);
gd.setCornerRadius(roundRadius);
gd.setStroke(strokeWidth, strokeColor);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment