my current XML::
For your requirement I prefer you to use CheckedTextView instead of CheckBox.Here is the code what you wanted.
create 3 xml ( chk_indicator.xml , chk_bg.xml , chk_pressed_bg.xml )in drawable folder
chk_indicator.xml
chk_bg.xml
-
chk_pressed_bg.xml
-
output:
set onClick event on CheckedTextView
((CheckedTextView)findViewById(R.id.ctv)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
boolean isChecked = ((CheckedTextView)findViewById(R.id.ctv)).isChecked();
if(isChecked)
((CheckedTextView)findViewById(R.id.ctv)).setChecked(false);
else
((CheckedTextView)findViewById(R.id.ctv)).setChecked(true);
}
});