问题
I have a ShapeDrawable
:
final ShapeDrawable drawable = new ShapeDrawable(shape);
drawable.getPaint().setStyle(Paint.Style.FILL);
drawable.getPaint().setColor(0xFFffffff);
I want to set border(stroke) color and width for this drawable.
I try setStyle(Paint.Style.FILL_AND_STROKE)
but it set background and border with same color
回答1:
Use
drawable.getPaint().setStyle(Paint.Style.STROKE);
drawable.getPaint().setStrokeWidth(2); // in pixel
来源:https://stackoverflow.com/questions/31103974/android-shapedrawable-set-background-and-border-programmatically