【问题标题】:How should I implement the RadioGroup?我应该如何实施 RadioGroup?
【发布时间】:2020-10-14 07:28:49
【问题描述】:

我有这个布局,它要求 2 个选项,你必须选择其中一个,所以我们需要在那里使用 RadioGroup 但每个 RadioButton 里面都有一个 Text 和一个 Image,我在 RadioButton 中查找重叠的图像并做它通过选择器(可绘制),但我无法。

布局文件:

【问题讨论】:

  • 我认为不使用RadioGroup 更好。只需每个点击事件。
  • 不,但我希望用户只选择两者之一
  • 您可以通过单击事件在选中时切换其他事件来处理此问题
  • 你能分享一些参考吗?
  • 为什么你需要使用 RadioGroup 而不是在点击一个按钮时改变另一个按钮的状态?

标签: android android-studio android-layout radio-button android-xml


【解决方案1】:

如何使用drawableTop制作RadioButton来显示图标?

 <RadioButton
    android:id="@+id/rad_home"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:background="@drawable/rad_background"
    android:button="@null"
    android:drawableTop="@drawable/home_icon"
    android:gravity="center"
    android:text="Home"
    android:textColor="@drawable/text_background"
    android:textSize="@dimen/rad_text_size" >

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-28
    • 2011-01-26
    • 2011-11-26
    • 1970-01-01
    • 2013-03-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多