我需要通过扩展ShapeDrawable以编程方式创建带圆角的边框.我需要一个带圆角的黑色边框,外面的像素是白色,内部像素是透明的.我目前的代码存在多个问题,其中的问题是它不会创建一个与边框厚度相同的平滑角,并且边框的外部像素是透明的而不是白色.
这是我目前得到的角落的图片 
这是我在构造函数中为'fill'传递Color.TRANSPARENT的代码:
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);
}
Run Code Online (Sandbox Code Playgroud)
}