开发者

Unexpected RadioButton behavior

Unexpected RadioButton behavior

Here is my layout:

<?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>

Why are the radio buttons superimposed over the text?


Problem was with the padding. Once I removed the padding, everything worked as usual. This might be a bug.


Why are you using a relative layout? Put the radiogroup in a linearlayout, then put the lienarlayout in the relativelayout.

Try changing the radiobutton layout_width from fill_parent to wrap_content


Is there a reason you're using RelativeLayout? That could be the problem.. Otherwise, I'd just increase the padding. I had this problem when using custom button images.


Use AppCompatRadioButton, this issue has been release in AppCompat 22.1 library

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜