title: How to programmatically create a round cornered border using ShapeDrawable in android?
body: <p>I need to create a border with rounded corners programatically by extending ShapeDrawable. I need to have a black border with rounded corners with the pixels on the outside being white and the inner pixels being transparent. The code I have at the moment has multiple problems, of which are that it does not create a smooth corner that is the same thickness as the border and that the outer pixels of the border are transparent and not white. </p>
  
  <p>Here is a picture of the corners I am currently getting <img src="https://i.stack.imgur.com/Soire.png" alt="corner"></p>
  
  <p>Here is the code where I am passing Color.TRANSPARENT for 'fill' in the constructor:</p>
  
  <pre><code>public class CustomShape extends ShapeDrawable {
   private final Paint fillpaint, strokepaint;
  public CustomShape(int fill, int strokeWidth,int radius) {
  
      super(new RoundRectShape(new float[] { radius, radius, radius, radius, radius, radius, radius, radius }, null, null));
      fillpaint = new Paint(this.getPaint());
      fillpaint.setColor(fill);
      strokepaint = new Paint(fillpaint);
      strokepaint.setStyle(Paint.Style.STROKE);
      strokepaint.setStrokeWidth(strokeWidth);
      strokepaint.setColor(Color.BLACK);
  }
  
  
  
  @Override
  protected void onDraw(Shape shape, Canvas canvas, Paint paint) {
      shape.draw(canvas, fillpaint);
      shape.draw(canvas, strokepaint);
  }
  </code></pre>
  
  <p>}</p>