У меня есть TableLayout
с 2 столбцами: метка и поле ввода (Spinner
, EditText
, RadioGroup
). Я хочу выровнять метку для RadioGroup
точно в вертикальном выравнивании с текстом первого переключателя. Текст «Возьми его» должен быть на красной линии. Как это сделать? Является ли это возможным?Совместите метку с текстом первого RadioButton
Вот XML - урезанная к соответствующему TableRow
:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layoutEditMedication1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="16dp"
tools:context=".Main" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/buttons" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="1"
android:stretchColumns="1" >
<TableRow style="@style/EditMedicationTableRowT" >
<TextView
style="@style/EditMedicationLabel"
android:layout_gravity="top"
android:text="@string/i_need_to_take" />
<RadioGroup
style="@style/EditMedicationTableRowB"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RadioButton
android:id="@+id/radioScheduleDaily"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/schedule_daily" />
<RadioButton
android:id="@+id/radioScheduleSpecial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/schedule_special" />
</RadioGroup>
</TableRow>
</TableLayout>
</ScrollView>
</RelativeLayout>
и используемые стили:
<resources>
<style name="EditMedicationTableRowT">
<item name="android:paddingTop">8dp</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="EditMedicationTableRowB">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:paddingBottom">8dp</item>
</style>
<style name="EditMedicationLabel">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">center_vertical</item>
<item name="android:paddingRight">16dp</item>
<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
</style>
</resources>
Я знаю, что я мог бы сделать два TableRows
с два разных RadioGroups
каждый с одним RadioButton
, а затем программно код что-то при этом они выглядят так, как будто они где-то RadioGroup
. Но, возможно, есть простое решение.
API - 8 и выше.
вы могли бы опубликовать XML вашего компоновщика? – zbr
сделано ................ – koem