try this, for Programmatically to set a background with radius to LinearLayout or any View.
private Drawable getDrawableWithRadius() {
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setCornerRadii(new float[]{20, 20, 20, 20, 20, 20, 20, 20});
gradientDrawable.setColor(Color.RED);
return gradientDrawable;
}
LinearLayout layout = new LinearLayout(this);
layout.setBackground(getDrawableWithRadius());