RadioButton与RadioContainer组件
在个人信息的选择中,一般都会涉及到性别的处理。而性别显然是一个单选问题,这种单选情况,在鸿蒙开发中需要使用RadioButton与RadioContainer组件。
本篇,将详细介绍RadioButton与RadioContainer组件的使用规则。
创建单选项
首先,我们用纯XML布局文件创建一个单选项选择组件。示例代码如下所示:
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:background_element="#98ffff"
ohos:orientation="vertical">
<RadioContainer
ohos:id="$+id:test_radiocontainer"
ohos:height="match_content"
ohos:width="match_content"
ohos:layout_alignment="horizontal_center"