意外的RadioButton行为

Rag*_*har 4 layout android radio-button

替代文字

这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFFFF">

<RadioGroup
    android:id="@+id/choices_group"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:layout_centerInParent="true"
    android:orientation="vertical"
    android:background="@drawable/rounded_bg" >

    <RadioButton
        android:id="@+id/choice_a"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:padding="5dp"
        android:text="Choice A" />

    <RadioButton
        android:id="@+id/choice_b"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="5dp"
        android:text="Choice B" />

    <RadioButton
        android:id="@+id/choice_c"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="5dp"
        android:text="Choice C" />

    <RadioButton
        android:id="@+id/choice_d"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="5dp"
        android:text="Choice D" />
</RadioGroup>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

为什么单选按钮叠加在文本上?

Rag*_*har 13

问题在于填充.一旦我删除填充,一切都照常工作.这可能是一个错误.

  • 为了完整性:这不是一个错误(至少在Android中不是).标签给出了一个透明的背景图像,这是一个9补丁,左侧有很多填充.此填充匹配实际单选按钮图像的大小.如果覆盖该填充,布局将被搞砸. (6认同)