Sunday, August 9, 2015

How to display a title for RadioGroup in Android

activity_main.xml

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rl"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp"
    tools:context=".MainActivity"
    android:background="#5fbe70"
    >
    <RadioGroup
        android:id="@+id/rg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="15dp"
        android:background="#b2ffb2"
        >
        <TextView
            android:id="@+id/tv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Which is your most favorite?"
            />
        <RadioButton
            android:id="@+id/rb_coldfusion"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="ColdFusion"
            android:paddingRight="15dp"
            />
        <RadioButton
            android:id="@+id/rb_flex"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Flex"
            android:paddingRight="15dp"
            />
        <RadioButton
            android:id="@+id/rb_flash"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Flash"
            android:paddingRight="15dp"
            />
    </RadioGroup>
</RelativeLayout>
More android examples