Android开发:文本控件详解——RadioButton和CheckBox(一)基本属性

这个博客的Android文章比较好,在此记录下他的博客论坛网址,学习时使用

博客论坛网址为:https://www.cnblogs.com/guobin-/p/10808173.html

 

一、RadioButton和RadioGroup:

  RadioButton是单个的圆形单选框,而RadioGroup是可以容纳多个RadioButton存在的容器,因此RadioButton和RadioGroup往往都配合使用。

  每个已经放入RadioGroup中的RadioButton只能有一个被选中,不放入RadioGroup中的RadioButton可以多选,和checkbox无异。

  1、简单实例:

<RadioGroup
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true">

        <RadioButton
            android:id="@+id/buttonSchool1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/school1"
            android:checked="true"/>

        <RadioButton
            android:id="@+id/buttonSchool2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/school2"/>

        <RadioButton
            android:id="@+id/buttonSchool3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/school3"/>

        <RadioButton
            android:id="@+id/buttonSchool4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/school4"/>

    </RadioGroup>

 

运行结果如下:

2、RadioGroup基本属性:

  (1)、orientation:排列方式

      若值为horizontal,则为横向,水平排列:

      android:orientation="horizontal"

 

若值为vertical,则为纵向,垂直排列。

      android:orientation="vertical"

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值