소스에서 적용법-------------------------------------------------------
int position = 0;
Button btnColor = (Button)findViewById(R.id.button);
btnColor.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (position == 0) {
btnColor.setBackgroundColor(Color.BLACK);
position++;
} else {
btnColor.setBackgroundColor(Color.WHITE);
position--;
}
}
});
xml적용법-------------------------------------------------------
버튼 xml에서
background = "@drawable/커스텀xml" 이렇게 하시고
커스텀xml에서
<item android:state_pressed="true"
android:drawable="@drawable/눌렀을때검정색인이미지"/>
<item android:state_focused="true"
android:drawable="@drawable/포커싱되있을때흰색이미지"/>
<item android:drawable="@drawable/평상시흰색이미지"/>
</selector>
입맛따라 두개중에 골라서 쓰세요