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;
}
'프로그래밍 > Android' 카테고리의 다른 글
Android Kotlin openPDF (0) | 2023.05.12 |
---|---|
android architecture components (AAC) 설명 및 샘플코드 (0) | 2020.02.21 |
안드로이드스튜디오 단축키 (0) | 2016.07.15 |
[Android]Android, MySQL, PHP, & JSON Tutorial (0) | 2014.12.03 |
[Android] Handler{} sending message to a Handler on a dead thread (0) | 2012.12.11 |