[안드로이드]컴파운드버튼(체크박스,라디오버튼,스위치,토글버튼) 한눈에 비교하기

[안드로이드]컴파운드버튼(체크박스,라디오버튼,스위치,토글버튼) 한눈에 비교하기

컴파운드버튼

컴파운드 버튼에는 체크박스, 라디오버튼, 스위치, 토글버튼등이 있다.
이 중 헷갈리는 생김새가 있어 비교해보려고한다.

종류 모양
체크박스 https://developer.android.com/guide/topics/ui/controls/checkbox#kotlin
라디오버튼 https://developer.android.com/guide/topics/ui/controls/radiobutton?hl=ko
토글버튼(Toggle) https://developer.android.com/guide/topics/ui/controls/togglebutton?hl=ko
스위치(Switches) https://developer.android.com/guide/topics/ui/controls/togglebutton?hl=ko




Radio버튼

  • Radio버튼은 꼭 RadioGroup과 함께 사용해야 여러 개 중 하나만 선택 가능하다.
  • RadioGroup은 사용하지않은채 Radio버튼만 사용하면 checkBox버튼처럼 중복 선택된다.
  • clearCheck() : 해당 라디오그룹안에 체크된 것을 모두 해제하는 메서드

https://developer.android.com/guide/topics/ui/controls/radiobutton?hl=ko

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<RadioGroup
android:id="@+id/rGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yes"
/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Maybe"
/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No"
/>
</RadioGroup>