RadioButton & RadioGroup
RadioButton 은 RadioGroup 과 함께 쓰이는 경우가 많다.
RadioGroup 에서는 group 안의 RadioButton 을 하나 선택할 경우 나머지 RadioButton 은 선택이 해제된다.
즉, 한번에 하나만 선택할 수 있다는 뜻이다.
How to
◼ RadioButton & RadioGroup code in XML
◼ RadioButton & RadioGroup code in JAVA
Attributes
◼ id
id 는 해당 RadioButton 을 유일하게 식별할 수 있는 속성이다.
◼ text
RadioButton 에 표시할 text 를 설정한다.
◼ checked
해당 RadioButton 을 선택 or 해제 할 수 있는 속성이다.
값은 "true" or "false" 이며 기본값은 "false" 이다.
◼ gravity
Text 를 정렬할 수 있는 속성이다.
- layout_width, layout_height 이 wrap_content 이면 text 가 정렬될 공간이 없어 정렬이 안된다.
- gravity 를 지정하지 않으면 기본 속성인 left, top 이 적용된다.
[Android/Layout] - TextView gravity (TextView gravity 와 동일하다.)
◼ textColor
Text 의 색상을 설정한다.
- “#argb”, “#rgb”, “#rrggbb”, or “#aarrggbb” 형태로 지정할 수 있다.
◼ textSize
Text 의 크기를 설정한다.
- sp(scale independent pixel) or dp(density pixel) 로 설정 할 수 있다.
◼ textStyle
Text 의 style 을 설정한다.
- "bold"(굵게), "italic"(이태릭), "normal"(기본) 을 설정할 수 있고 "|" 로 2개 이상의 설정을 할 수 있다.
◼ background
RadioButton 의 배경색을 설정한다.
- color 값이나 drawable 을 설정할 수 있다.
◼ padding
RadioButton 의 왼쪽, 오른쪽, 위, 아래 padding 을 설정한다.
◼ drawableBottom, drawableTop, drawableLeft, drawableRight
drawable 객체를 표시할 위치를 지정한다.