체크박스의 이미지 변경 ( selector 이용)
xml 파일을 새로 만들어준다. ( 본 포스팅에서는 checkbox.xml로 xml파일을 만들어줌 )
생성해준 xml파일은 drawable 폴더에다 해주었다.
< ?xml version="1.0" encoding="utf-8"?>
< selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:drawable="@drawable/Checked가 false일 때, 이미지 파일" />
<item android:state_checked="true" android:drawable="@drawable/Checked가 true일 때, 이미지 파일" />
<item android:drawable="@drawable/기본 이미지, 보통 false 일 때의 이미지를 사용한다." />
< /selector>
그리고 체크박스를 사용할 xml / layout에 CheckBox 생성
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:checked="true"
android:text="체크박스"
android:button="@null"
android:background="@android:color/transparent"
android:drawableLeft="@drawable/checkbox" />
이부분이 중요하다. 만들어준 셀렉터 파일명을 적어준다.
android:drawableLeft="@drawable/checkbox"
'MOBILE' 카테고리의 다른 글
이미지버튼 사이즈 조절 (0) | 2016.08.21 |
---|---|
selector로 버튼 액션 이미지 변경 (0) | 2016.08.21 |
슬라이딩 메뉴 - SimpleSideDrawer (0) | 2016.08.21 |
C서버와 소켓통신 (0) | 2016.08.21 |
Custom ListView (커스텀 리스트뷰) Footer를 이용한 더보기 구현 (0) | 2016.08.21 |
뒤로가기(Back 버튼) 두번 눌러 앱 종료하기 (0) | 2016.08.21 |
파일 생성 및 저장 (0) | 2016.08.21 |
현재시간(Local Time) 가져오기 (0) | 2016.08.21 |
댓글