android.graphics.drawable.ShapeDrawable shape = new android.graphics.drawable.ShapeDrawable(new android.graphics.drawable.shapes.RectShape());
shape.getPaint().setColor(Color.RED);shape.getPaint().setStyle(Paint.Style.STROKE);
shape.getPaint().setStrokeWidth(3);
edittext1.setBackground(shape);