Question

I want to have a Customized Radio Group view. So i have created xml view as below

<RadioGroup
    android:id="@+id/selectUserRadioBtnContainer"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="wrap_content" >
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:paddingRight="30dp"
                android:gravity="center_vertical"
                android:orientation="horizontal" >
                <ImageView
                    android:layout_width="50dp" 
                    android:layout_height="50dp" 
                    android:textSize="14sp"
                    android:fontFamily="normal"
                    android:layout_gravity="left|center_vertical"
                    android:text="@string/btnTextAddPic"
                    android:cropToPadding="true"
                    android:layout_marginTop="5dp"
                    android:layout_marginRight="10dp"
                    android:layout_marginBottom="5dp"
                    android:textColor="#ffffff" 
                           android:background="@drawable/profile_pic_rounded_background" />
                <TextView
                    android:id="@+id/txtUserFullName"
                    style="@style/reviewInputLabels"
                    android:layout_width="0dip"
                    android:layout_height="30dp"
                    android:textColor="#33B5E5"
                    android:gravity="center_vertical|left"
                    android:textSize="16sp"
                    android:layout_weight="1"
                    android:text="Patient Name"/>
                <RadioButton
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:checked="true"
                    android:tag="MAINUSER"
                    style="@style/radLabel"
                    android:button="@drawable/button_radion_default_custom" />
            </LinearLayout>
                   <LinearLayout
            android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:paddingRight="30dp"
                android:gravity="center_vertical"
                android:orientation="horizontal" >
                <ImageView
                    android:layout_width="50dp" 
                    android:layout_height="50dp" 
                    android:textSize="14sp"
                    android:fontFamily="normal"
                    android:layout_gravity="left|center_vertical"
                    android:text="@string/btnTextAddPic"
                    android:cropToPadding="true"
                    android:layout_marginTop="5dp"
                    android:layout_marginRight="10dp"
                    android:layout_marginBottom="5dp"
                    android:textColor="#ffffff"
                    android:background="@drawable/profile_pic_rounded_background" />
                <TextView
                    android:id="@+id/txtUserFullName"
                    style="@style/reviewInputLabels"
                    android:layout_width="0dip"
                    android:layout_height="30dp"
                    android:textColor="#33B5E5"
                    android:gravity="center_vertical|left"
                    android:textSize="16sp"
                    android:layout_weight="1"
                    android:text="Patient Name"/>
                <RadioButton
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:checked="true"
                    android:tag="MAINUSER"
                    style="@style/radLabel"
                    android:button="@drawable/button_radion_default_custom" />
        </LinearLayout>
        </RadioGroup>

Is this a right way to do?. The problem that I am facing is Radio buttons are not considered as children of Radio Group. Can anybody help me out with this ?

Was it helpful?

Solution

Try this for placing text and image on left of radio button

<RadioButton
    android:id="@+id/rbtnid"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:background="@color/white"
    android:button="@null"
    android:drawablePadding="30dp"
    android:drawableRight="@android:drawable/btn_radio"
    android:text="rtext"
    android:gravity="center|right"/>

Hope it helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top