안드로이드
[안드로이드] shape 라운드 버튼 색상 변경 (android change round button color)
Poohya
2015. 10. 30. 11:02
- 버튼 백그라운드에 shape 속성만 있다면 getBackground()의 drawable은 GradientDrawable 이다.
GradientDrawable d = (GradientDrawable) myView.getBackground();
d.setColor(Color.YELLOW);
- 버튼 background가 selector 이면 getBackground()의 drawable은 StateListDrawable 이다.
그러나 press등의 state를 가지지않을 때 변경을 시도했으나 변경되지않음. 추후에 더 테스트 해볼 것
StateListDrawable states = (StateListDrawable) myView.getBackground();
states.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(Color.YELLOW));