【问题标题】:Radio Button and Radio Group in Android [closed]Android中的单选按钮和单选组[关闭]
【发布时间】:2021-02-01 14:23:18
【问题描述】:

您好,我正在尝试将这些单选按钮放在 Radio Group 中,但我遇到的问题是它们没有按照我想要的方式进行。我附上这张图片是为了向您展示 2 个不同的单选按钮,它们目前不在单选组中,但是一旦我把它放在单选组中,它们就会垂直出现,我想使用单选组来获取这 2 个单选按钮并排,它们之间有一些空间,但似乎找不到路。

我想在做广播组时得到这些结果。我尝试了定向,但仍然没有帮助。

任何帮助将不胜感激。

【问题讨论】:

标签: java android


【解决方案1】:

试试这个

<RadioGroup
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <androidx.appcompat.widget.AppCompatRadioButton
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content" />

            <androidx.appcompat.widget.AppCompatRadioButton
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content" />

  </RadioGroup>

【讨论】:

    【解决方案2】:

    您可以在 RadioGroup 上添加方向。例如:

    <RadioGroup
       android:id="@+id/radio_group"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content" 
       android:orientation='horizontal'>
    

    【讨论】:

      猜你喜欢
      • 2011-05-10
      • 2015-03-16
      • 1970-01-01
      • 2011-10-19
      • 2018-12-14
      • 1970-01-01
      • 1970-01-01
      • 2021-12-29
      • 1970-01-01
      相关资源
      最近更新 更多