I have a layout with three images and three radio buttons below each image. I want that if one button is checked, then I know the user has selected the above image. Here's my layout file:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:gravity="center_horizontal">
<LinearLayout
android:id="@+id/frontRadioLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/frontShotIV"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/border_image_bkg"
android:src="@drawable/ic_hair_tools"
android:scaleType="centerCrop"/>
<RadioButton
android:id="@+id/radioFrontImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
<LinearLayout
android:id="@+id/sideRadioLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toRightOf="@id/frontRadioLayout"
android:layout_marginLeft="16dp">
<ImageView
android:id="@+id/sideShotIV"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/border_image_bkg"
android:src="@drawable/ic_hair_tools"
android:scaleType="centerCrop"/>
<RadioButton
android:id="@+id/radioSideImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
<LinearLayout
android:id="@+id/backRadioLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toRightOf="@id/sideRadioLayout"
android:layout_marginLeft="16dp">
<ImageView
android:id="@+id/backShotIV"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/border_image_bkg"
android:src="@drawable/ic_hair_tools"
android:scaleType="centerCrop"/>
<RadioButton
android:id="@+id/radioBackImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
</RelativeLayout>
The layout is rendered properly but this behavior occurs while testing - all the buttons get checked and can't be unchecked. I have tried simplifying my layout to this:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:gravity="center_horizontal">
<ImageView
android:id="@+id/frontShotIV"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/border_image_bkg"
android:scaleType="centerCrop"
android:src="@drawable/ic_hair_tools" />
<RadioButton
android:id="@+id/radioFrontImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/frontShotIV"
android:gravity="center_horizontal"
android:layout_marginLeft="33dp"/>
<ImageView
android:id="@+id/sideShotIV"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/border_image_bkg"
android:scaleType="centerCrop"
android:src="@drawable/ic_hair_tools"
android:layout_toRightOf="@+id/frontShotIV"
android:layout_marginLeft="16dp"/>
<RadioButton
android:id="@+id/radioSideImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/frontShotIV"
android:gravity="center_horizontal"
android:layout_toRightOf="@+id/frontShotIV"
android:layout_marginLeft="46dp"/>
<ImageView
android:id="@+id/backShotIV"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/border_image_bkg"
android:src="@drawable/ic_hair_tools"
android:scaleType="centerCrop"
android:layout_toRightOf="@+id/sideShotIV"
android:layout_marginLeft="16dp"/>
<RadioButton
android:id="@+id/radioBackImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/backShotIV"
android:layout_toRightOf="@+id/sideShotIV"
android:layout_marginLeft="46dp"/>
</RelativeLayout>
but it stills yields the same checked all behavior. Can anyone help me in rectifying this issue with the layout radio buttons to check individually and uncheck when another one is selected? Thanks.