我有一个ShapeDrawable:

final ShapeDrawable drawable = new ShapeDrawable(shape);
drawable.getPaint().setStyle(Paint.Style.FILL);
drawable.getPaint().setColor(0xFFffffff);

我想为此可绘制对象设置边框(描边)颜色和宽度。

我尝试setStyle(Paint.Style.FILL_AND_STROKE)但是它用相同的颜色设置背景和边框

最佳答案


drawable.getPaint().setStyle(Paint.Style.STROKE);
drawable.getPaint().setStrokeWidth(2); // in pixel

10-08 18:00