Java tutorial
//package com.java2s; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.RoundRectShape; public class Main { public static ShapeDrawable getShapeDrawable(int color, int radius) { RoundRectShape roundRectShape = new RoundRectShape( new float[] { radius, radius, radius, radius, radius, radius, radius, radius }, null, null); ShapeDrawable shapeDrawable = new ShapeDrawable(roundRectShape); shapeDrawable.getPaint().setColor(color); return shapeDrawable; } }