Android单选按钮左填充为0

标签 android android-radiobutton

需要有关单选按钮的帮助

我的xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

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

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="0dp"
            android:minWidth="0dp"
            android:text="Hello" />

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="0dp"
            android:text="World" />
    </RadioGroup>

</LinearLayout>

在圆形和线性布局左侧之间的左侧有这个空间。我如何摆脱那个空间?在 TextViews 中,将 minWidth 设置为 0dp 可以解决问题,但我无法为 RadioButtons 做到这一点。任何想法

最佳答案

方法不多,你可以试试这个

<RadioGroup
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_marginLeft="-10dp" 
    >

... android:layout_marginLeft="-10dp"

它能满足您的需求吗?

关于Android单选按钮左填充为0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24190564/

相关文章:

android - 运行 android lint 报错

android - 防止反射 - android

android - 在下载文件之前从 URL 解析文件名

java - 单击时 RadioGroup 失败

android - 如何找出选定的单选选项,当 android :radiobutton ="@null" in android?

android - 更改单选按钮的圆圈颜色

java - 向上/向下滚动时检查复选框缺失

android - 在 Android 2.2 上运行时错误膨胀类 android.support.v4.app.fragment

Android 自定义复选框/单选按钮文本不显示

Android RadioButton *带有*图标并居中对齐