RadioGroup分频器没有显示

时间:2014-06-20 16:37:30

标签: android android-layout radio-button

我不知道为什么我的RadioGroup分频器没有显示。有人请说清楚。我已经看过Android radiogroup, divider between radiobuttons

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:divider="@drawable/divider_color"
        android:showDividers="middle" >

        <RadioButton
            android:id="@+id/first"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:button="@null"
            android:checked="true"
            android:drawableRight="@android:drawable/btn_radio"
            android:text="First" />

        <RadioButton
            android:id="@+id/second"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:button="@null"
      android:drawableRight="@android:drawable/btn_radio"
      android:text="second" />

        <RadioButton
            android:id="@+id/third"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:button="@null"
      android:drawableRight="@android:drawable/btn_radio"
      android:text="third" />
    </RadioGroup>

</LinearLayout>

divider_color的形状是

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" >

    <solid android:color="#000000" />

</shape>

1 个答案:

答案 0 :(得分:0)

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" >

    <stroke
        android:width="1dp"
        android:color="#000000" />
    <size android:height="2dip" />
</shape>

如上所述更新您的drawable或使用下面的

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:height="1dp"></size>
<solid android:color="#000000" />