У меня есть следующий относительный код макета в моем Android приложение:Совместите изображения рядом с Radiobuttons в RadioGroup
<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" />
Он производит макет, который выглядит следующим образом:
Это просто поэтому происходит правильное выравнивание из-за размера изображения ImageButtons
. Я недавно переработал приложение, а ImageButtons
с правой стороны больше не выстраивается в линию с RadioButtons
.
Есть ли более надежный способ построения такого макета, так что ImageButtons
всегда выравниваются с соответствующими RadioButtons
?