【发布时间】:2023-03-05 22:52:01
【问题描述】:
我无法将我的广播组定位在按钮上。它以相对布局返回按钮。我想要的是一个按钮上的广播组。我已经添加了代码的输出。我想要的是把收音机组放在 2 个按钮上。谁能帮我解决这个 UI 问题?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
tools:context=".MainActivity">
<Button
android:id="@+id/buttonBelow"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerInParent="true"
android:background="#f00"
android:text="Button Below" />
<Button
android:id="@+id/buttonAbove"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
android:background="#ff0"
android:text="Button Above" />
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#00f">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Male" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female" />
</RadioGroup>
</RelativeLayout>
【问题讨论】:
-
添加应用的当前屏幕截图以进行可视化。
-
如果您发布当前输出和预期输出的图像会很好。
-
@Zlytherin 当前屏幕截图与应用程序中的相同。我希望这两个按钮都回到前面的收音机组和收音机组。
-
@RumitPatel 我想要收音机组在前面,两个按钮在后面
-
@AmitMishra,检查我的答案。
标签: android user-interface android-relativelayout android-radiogroup