Android ApiDemos示例解析(107):Views->Controls->1. Light Theme
<RadioGroup android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”vertical”> <RadioButton android:id=”@+id/radio1″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”@string/controls_1_radiobutton_1″ /> <RadioButton android:id=”@+id/radio2″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”@string/controls_1_radiobutton_2″ /> </RadioGroup>
此外,CheckBox 可以定义不同的风格,比如本例使用一个“星星”形状:
<CheckBox android:id=”@+id/star”
style=”?android:attr/starStyle”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”@string/controls_1_star” />
其实大部分UI控件都可以自定义风格。
本例和下例一个使用“浅色”风格,一个使用缺省风格,这是通过在AndroidMainifest.xml 为Activity 定义了不同的风格,比如本例:
<activity android:name=”.view.Controls1″
android:label=”Views/Controls/1. Light Theme”
android:theme=”@android:style/Theme.Light”>
<intent-filter>
< action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.SAMPLE_CODE” />
< /intent-filter>
< /activity>