본문으로 바로가기
728x90

체크박스의 색상(color)지정


아래와 같이 코딩하시면 됩니다...


1
buttonView.setButtonTintList(ColorStateList.valueOf(Color.parseColor("#34BFD6")))
cs




체크박스가 체크 되었을때와 해제 되었을때 각각 다른색으로 표현 할경우


1
2
3
4
5
6
7
8
9
10
checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
            buttonView.setButtonTintList(ColorStateList.valueOf(Color.parseColor("#34BFD6")));
        } else {
            buttonView.setButtonTintList(ColorStateList.valueOf(Color.parseColor("#757575")));
        }
    }
});
cs


isChecked는 체크박스의 체크여부 Boolean을 나타냅니다.

728x90