How to create this shape programmatically?
You can also use OVAL shape instead of rectangle:
OVAL
GradientDrawable shape = new GradientDrawable(); shape.setShape(GradientDrawable.OVAL); shape.setColor(Color.WHITE); shape.setStroke(2, Color.BLACK); view.setBackground(shape);