Based on the answer from @nmw, here's some code that works for this:
public class RRDrawable extends Drawable {
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
public RRDrawable(int color) {
paint.setColor(color);
paint.setStyle(Paint.Style.FILL);
}
@Override
public void draw(Canvas canvas) {
int radius = 10; // note this is actual pixels
canvas.drawRoundRect(new RectF(0,0,canvas.getWidth(), canvas.getHeight()), radius, radius, paint);
}
@Override
public void setAlpha(int i) {
//.. not supported
}
@Override
public void setColorFilter(ColorFilter colorFilter) {
//.. not supported
}
@Override
public int getOpacity() {
return 1;
}
}
EDIT: added anti-aliasing to the edges.
(source)