public static void setButtonBackground(Button btn, int normal_color, int press_color) {
StateListDrawable res = new StateListDrawable();
res.addState(new int[]{android.R.attr.state_pressed}, setGradientColors(normal_color));
res.addState(new int[]{}, setGradientColors(press_color));
btn.setBackground(res);
}

public static GradientDrawable setGradientColors(int color) {
GradientDrawable gradient = new GradientDrawable();
gradient.setShape(GradientDrawable.RECTANGLE);
gradient.setColor(color);
gradient.setCornerRadius(120.f);
return gradient;
}


+ Recent posts