个人知识总结:View篇--RadioButton、RadioGroup

RadioGroup: This class is used to create a multiple-exclusion scope for a set of radio buttons. Checking one radio button that belongs to a radio group unchecks any previously checked radio button within the same group.
RadioButton: A radio button is a two-states button that can be either checked or unchecked. When the radio button is unchecked, the user can press or click it to check it. However, contrary to a {@link android.widget.CheckBox}, a radio button cannot be unchecked by the user once checked.

以上是Google对于RadioButton和RadioGroup的介绍,主要用于和ViewPager的联合使用来切换fragment的选择的,但是实际开发中已经很少使用了,因为Google退出了更加简便的方式实现RadioGroup和RadioButton组合使用可以达到的效果,后续会总结到的(TabLayout和BottomNavigationView)。

RadioGroup和RadioButton属性

RadioButton是TextView的间接子类,拥有TextView的所有属性,但是在RadioButton的直接父类CompoundButton又加入了几个新的属性:

1、android:button 设置一个给定其资源标识符的复合按钮图像
2、android:checked 设置初始的按钮选中状态
3、android:buttonTint 给可绘制按钮涂上颜色,不修改默认的当前色调模式。
4、android:buttonTintMode 设置色调模式(具体的可以去看PorterDuff类,默认是SRC_IN)

RadioGroup是LinearLayout的直接子类,拥有LinearLayout的所有属性,同样的为了和RadioButton联合使用,也加入了一个新的属性:

1、android:checkedButton 设置初始化是选中的RadioButton

总的来说,这两个控件使用起来还是很简单的,也没有过多的属性,都是一些浅显易懂的,基本上看一遍都可以直接使用起来的。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 7,593评论 0 3
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,150评论 0 10
  • The Inner Game of Tennis W Timothy Gallwey Jonathan Cape ...
    网事_79a3阅读 14,248评论 3 20
  • 佛,不是有难时所求生穷时求财,佛该是一种信仰, 让你难时保持平静,穷时找到追求。佛不等于你迷信,很多人没有明白这个道理。
    流浪者之歌01阅读 1,202评论 0 1
  • 去A市参展,我们随身携带了一部分样品。我跟沫沫每人一个28寸的行李箱,里面满满当当的,感觉手里有几百斤。这对俩女生...
    年千子阅读 3,355评论 3 9