当前位置:   article > 正文

自定义RadioGroup实现radioButton多行多列_android radiobutton 2行2列,4选1

android radiobutton 2行2列,4选1

     前段时间我需要一个2行2列的单选组合按钮,效果如下:

但是发现在RadioGroup添加布局的时候就会失去radioButton的互斥行,我上网查了一下相关的自定义RadioGroup的方法,希望能够找到能如意在里面随意布局的,但是貌似没有找到,好像都是根据各自的情况重写的RadioGroup,于是我就自己写按照自己的需求修改了一个例子实现RadioGroup多行多列

先上布局代码:

  1. <com.hecai.caipiao.football.MyRadioGroup
  2. android:id="@+id/sporttery_football_peilv_group"
  3. android:layout_width="fill_parent"
  4. android:layout_height="wrap_content"
  5. android:orientation="vertical" >
  6. <LinearLayout
  7. android:layout_width="fill_parent"
  8. android:layout_height="wrap_content"
  9. android:layout_marginLeft="10.0dip"
  10. android:layout_marginRight="10.0dip"
  11. android:orientation="horizontal" >
  12. <LinearLayout
  13. android:layout_width="fill_parent"
  14. android:layout_height="wrap_content"
  15. android:layout_weight="1"
  16. android:orientation="horizontal" >
  17. <RadioButton
  18. android:id="@+id/sporttery_football_all_check"
  19. android:layout_width="wrap_content"
  20. android:layout_height="wrap_content"
  21. android:background="@null"
  22. android:button="@null"
  23. android:drawableLeft="@drawable/radio_botton"
  24. android:drawablePadding="3.0dip"
  25. android:text="全部"
  26. android:textColor="@color/black"
  27. android:textSize="18.0sp" />
  28. <TextView
  29. android:id="@+id/sporttery_football_high_check_label"
  30. android:layout_width="wrap_content"
  31. android:layout_height="wrap_content"
  32. android:layout_marginLeft="2.0dip"
  33. android:gravity="center_vertical"
  34. android:includeFontPadding="false"
  35. android:singleLine="true"
  36. android:text="全部区间" />
  37. </LinearLayout>
  38. <LinearLayout
  39. android:layout_width="fill_parent"
  40. android:layout_height="wrap_content"
  41. android:layout_weight="1"
  42. android:orientation="horizontal" >
  43. <RadioButton
  44. android:id="@+id/sporttery_football_low_check"
  45. android:layout_width="wrap_content"
  46. android:layout_height="wrap_content"
  47. android:background="@null"
  48. android:button="@null"
  49. android:drawableLeft="@drawable/radio_botton"
  50. android:drawablePadding="3.0dip"
  51. android:text="1.5以下"
  52. android:textColor="@color/black"
  53. android:textSize="18.0sp" />
  54. <TextView
  55. android:id="@+id/sporttery_football_low_check_label"
  56. android:layout_width=
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/一键难忘520/article/detail/864209
推荐阅读
相关标签
  

闽ICP备14008679号