CompoundButton Classjava.lang.Object
android.view.View
android.widget.TextView
android.widget.Button
android.widget.CompoundButton
android.widget.CheckBox
android.widget.RadioButton
android.widget.Switch
android.widget.ToggleButton
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/android"
android:text="Android Phone"
android:checked="true"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/iphone"
android:text="Iphone"
android:checked="true"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/window"
android:text="Window phone"
android:checked="false"/>
CheckBox Java 처리1. 체크박스 변수 선언
CheckBox myc;
2. 변수에 체크박스 위젯 대입
myc=(CheckBox)findViewById(R.id.checkid1)
3. 체크박스가 변경될 때 동작하는 클래스 정의
myc.setOnCheckedListener(new CompoundButton.OnCheckedChangedListener(){
public void onCheckedChanged(){
// java 동작
}
});
Switch & ToggleButton스위치는 좌우로 넘기는 GUI 제공, Toggle On/Off로 GUI 제공
toggle

<Switch
android:layout_widget="wrap_content"
android:layout_height="wrap_content"
android:checked="true"/>
<Switch
android:layout_widget="wrap_content"
android:layout_height="wrap_content"
android:checked="false"/>
<ToggleButton
android:layout_widget="wrap_content"
android:layout_height="wrap_content"
android:checked="true"/>
<ToggleButton
android:layout_widget="wrap_content"
android:layout_height="wrap_content"
android:checked="false"/>
RadioGroup & RadioButtonRadioGroup 내에서는 하나만 선택 가능
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:"@+id/rGroup1">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"/>
</RadioGroup>
ImageView & ImageButtonjava.lang.Object
android.view.View
android.wiget.ImageView
android.widget.ImageButton
app-res-drawable 에 사용할 사진 저장
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:layout_margin="5dp"
android:src="@drawable/r11.png"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:src="@drawable/r11.png"/>
<ImageView
android:layout_width="300dp"
android:layout_height="100dp"
android:scaleType="fitXY"
android:src="@drawable/r11.png"/>
<ImageView
android:layout_width="300dp"
android:layout_height="100dp"
android:scaleType="fitCenter"
android:src="@drawable/r11.png"/>
위 소스코드에서 r11.png에서 .png 생략해도 무방
scaleType
fitXY-설정한 크기로 이미지를 꽉 채움
fitCenter-설정한 크기에 가운데에 맞춤
(fitStart, fitEnd 등으로 설정 가능)