【问题标题】:How to reduce space between radiobuttons in a radiogroup in android?如何减少android中radiogroup中radiobutton之间的空间?
【发布时间】:2013-08-03 18:19:34
【问题描述】:

在我的应用程序中,我有一个对话框,其中包含一个带有四个单选按钮的单选组。我的问题是它在模拟器中看起来不错,但是当我在手机中安装和运行我的应用程序时,单选按钮在每个单选按钮之间获得了更多空间。这使得无线电组延伸到我的对话框之外。 请帮我解决一下这个。 谢谢。

<RadioGroup
        android:id="@+id/radio_RemindAtDlg"
        android:layout_width="wrap_content"
        android:layout_height="130dp"
        android:layout_marginTop="110dp"
        android:layout_marginLeft="20dp" >

        <RadioButton
            android:id="@+id/radio_OnceDlg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Once"
            android:button="@drawable/radio_button"
            android:textSize="12dp" />

        <RadioButton
            android:id="@+id/radio_WeekDlg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Every Week"
            android:button="@drawable/radio_button"
            android:textSize="12dp" />

        <RadioButton
            android:id="@+id/radio_MonthDlg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Every Month"
            android:button="@drawable/radio_button"
            android:textSize="12dp" />

        <RadioButton
            android:id="@+id/radio_YearDlg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Every Year"
            android:button="@drawable/radio_button"
            android:textSize="12dp" />

    </RadioGroup>

【问题讨论】:

  • 我们可以看看你代码的相关部分吗?
  • 那里有我的无线电组代码

标签: android radio-button space reduce radio-group


【解决方案1】:

没有代码很难说,但我猜您将 xml 高度属性设置为 fill_parent 而不是 wrap_content

【讨论】:

  • 您将高度设置为固定大小,将其更改为包裹内容
【解决方案2】:

使用您自己的尺寸、形状和组件之间的空间定义您自己的单选按钮:

http://blog.devminded.com/posts/custom-android-radiobutton

另一个例子

https://stackoverflow.com/a/17693303/1276374

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-17
    • 2010-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-19
    • 2020-08-10
    相关资源
    最近更新 更多