RadioButtons with TextView in RadioGroup

Michal picture Michal · Apr 24, 2012 · Viewed 8.6k times · Source

Is it possible to add TextView below RadioButton in RadioGroup in any other way than extending and creating my custom RadioButton?

Answer

waqaslam picture waqaslam · Apr 24, 2012

Yes, its possible. See below:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <RadioGroup
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="btn1" />

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="btn2" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="sample text" />

    </RadioGroup>

</LinearLayout>

Sample output:

enter image description here