文章目录 概述 基本使用 在xml布局中定义RadioButton 在Activity中获取RadioButton 样式设置 在xml中进行设置 在Java中实现 自定义样式 文字样式自定义 其他设置 动态添加`RadioButton` 设置默认选中项 通过xml设置 通过Java设置 获取选中的单选按钮 清除选择 事件 选择事件 实例 性别单选按钮 概述 RadioButton(单选按钮)是 Android 中常用的选择控件,通常与 RadioGroup 配合使用,实现一组互斥的选择项。 RadioButton 必须放在RadioGroup才能实现单选,如果需要多选功能则使用CheckBox。 基本使用 在xml布局中定义RadioButton android:orientation="horizontal"表示让单选按钮组内的组件水平排放。 <RadioGroup android:id="@+id/radioGroup