How to create android shape background programmatically?

前端 未结 5 1706
无人共我
无人共我 2020-12-13 03:35

How to create this shape programmatically?




        
5条回答
  •  粉色の甜心
    2020-12-13 04:20

    You can also use OVAL shape instead of rectangle:

    GradientDrawable shape = new GradientDrawable();
    shape.setShape(GradientDrawable.OVAL);
    shape.setColor(Color.WHITE);
    shape.setStroke(2, Color.BLACK);
    view.setBackground(shape);
    

提交回复
热议问题