Я хочу RadioGroup
с различными RadioButtons
отображается в двух столбцах. Но кажется, что RadioGroup
заставляет RadioButtons
отображаться всего в одной колонке. Есть ли способ, чтобы кнопки отображались в двух столбцах?Android RadioGroup. Вынужденные кнопки в одной колонке?
Например, этот xml-код помещает четыре кнопки в square form
, но внутри RadioGroup все они находятся в one column
.
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radio1"
android:text="Button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<RadioButton
android:id="@+id/radio2"
android:text="Button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="42dp"
android:layout_marginEnd="42dp"
android:layout_alignBottom="@+id/radio1"/>
<RadioButton
android:id="@+id/radio3"
android:text="Button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/radio1"
android:layout_alignLeft="@+id/radio1"
android:layout_alignStart="@+id/radio1"
android:layout_marginTop="34dp"/>
<RadioButton
android:id="@+id/radio4"
android:text="Button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/radio3"
android:layout_alignLeft="@+id/radio2"
android:layout_alignStart="@+id/radio2"/>
</RadioGroup>
RadioGroup расширяет LinearLayout, поэтому просто это невозможно. Вы можете переопределить RelativeLayout и выполнить в нем некоторую логику проверки/отмены. – convexHull
@convexHull И как я могу переопределить его и получить эти кнопки в виде квадратной формы? –
Проверьте это https://developer.android.com/training/custom-views/index.html Создайте некоторый класс (например, RelativeRadioGroup), и пусть он расширяет RelativeLayout. Проверьте исходный код для RadioGroup, чтобы узнать, как реализовать дополнительную логику для проверки/снятия кнопок – convexHull