I have the following relative layout code in my Android app:
<RadioGroup
android:id="@+id/selectSound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/micLevelLabel"
android:checkedButton="@+id/radiohighpitched"
android:layout_marginTop="71dp" >
<RadioButton
android:id="@+id/radiohighpitched"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="High Pitched"
android:textColor="@color/android:white"
/>
<RadioButton
android:id="@+id/radiofoghorn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fog Horn"
android:textColor="@color/android:white"
/>
<RadioButton
android:id="@+id/radioalarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Alert Tone"
android:textColor="@color/android:white" />
</RadioGroup>
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageButton1"
android:layout_below="@+id/imageButton1"
android:onClick="playTone2"
android:src="@drawable/play_med" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageButton2"
android:layout_below="@+id/imageButton2"
android:onClick="playTone3"
android:src="@drawable/play_med" />
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/selectSound"
android:layout_toRightOf="@+id/micLevelLabel"
android:onClick="playTone1"
android:src="@drawable/play_med" />
It produces a layout that looks like this:
It just so happens to line up correctly because of the image size of the ImageButtons
. I've recently redesigned the app and the ImageButtons
on the right hand side no longer line up with the RadioButtons
.
Is there a more robust way to construct this layout such that the ImageButtons
always align with the corresponding RadioButtons
?