Я разрабатываю приложение обратной связи, которое должно иметь макет, аналогичный этому экрану. [1]: https://i.stack.imgur.com/xn3kh.jpg
Я разработал xml для макета.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.zankrutparmar.feedback.Frag_one">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/frag_one_title"
android:textColor="#fff"
android:textStyle="bold|italic"
android:textSize="35dp"
android:textAlignment="center"/>
<LinearLayout
android:layout_width="819dp"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginEnd="@dimen/activity_vertical_margin"
android:text="Poor"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="35dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_vertical_margin"
android:text="Average"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="35dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_vertical_margin"
android:text="Good"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="35dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_vertical_margin"
android:text="Very Good"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="35dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_vertical_margin"
android:text="Excellent"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="35dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="6">
<TextView
android:layout_width="58dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_vertical_margin"
android:layout_weight="1"
android:text="Theme & Decor"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="25dp"
android:textStyle="bold|italic" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_vertical_margin"
android:layout_weight="5"
android:orientation="horizontal">
<RadioButton
android:id="@+id/poor1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/custom_btn_radio_poor"
android:button="@null" />
<RadioButton
android:id="@+id/average1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/custom_btn_radio_average"
android:button="@null" />
<RadioButton
android:id="@+id/good1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/custom_btn_radio_good"
android:button="@null" />
<RadioButton
android:id="@+id/very1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/custom_btn_radio_very_good"
android:button="@null" />
<RadioButton
android:id="@+id/excellent1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/custom_btn_radio_excellent"
android:button="@null" />
</RadioGroup>
</LinearLayout>
Now whenever I want to apply margin to these radio buttons the center one remains in center and pushes all other buttons far.
Я также пробовал ответы на этот вопрос [1]: радиогруппы с соответствующими метками, выровненными в android
Но в этом макете проблема заключается в том, что выбираются все кнопки в одной строке. Это означает, что Radiogroup не может быть размещена в этом макете.
И я должен получить вопросы из базы данных и поместить их в свое приложение. Так что в будущем мне придется динамически добавлять строки. Любая помощь будет очень признательна. Заранее спасибо.