【发布时间】:2015-12-27 01:51:39
【问题描述】:
我有一个单选组,其中有 4 个单选按钮。我希望它们对齐为两条水平线,即水平的两个单选按钮和水平的其他两个单选按钮,位于第一个水平单选按钮的下方。
如何在不改变其功能的情况下完成此操作
这意味着只能选择一个单选按钮。
这是我的简单代码:
<RadioGroup
android:id="@+id/radiogroup_relation_options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/HeadingText"
android:background="#4269c6" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<RadioButton
android:id="@+id/radiobutton_friend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:button="@drawable/custom_radiobutton"
android:padding="5dp"
android:paddingLeft="10dp"
android:text="Friend"
android:textSize="15sp" />
<RadioButton
android:id="@+id/radiobutton_business"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:button="@drawable/custom_radiobutton"
android:padding="5dp"
android:paddingLeft="10dp"
android:text="We've done Business Together"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<RadioButton
android:id="@+id/radiobutton_colleague"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:button="@drawable/custom_radiobutton"
android:padding="5dp"
android:paddingLeft="10dp"
android:text="Colleague"
android:textSize="15sp" />
<RadioButton
android:id="@+id/radiobutton_other"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:button="@drawable/custom_radiobutton"
android:padding="5dp"
android:paddingLeft="10dp"
android:text="Other"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</RadioGroup>
【问题讨论】:
-
使用
android:weight -
请附上您的 XML 代码。我会编辑它并给你解决方案
-
嘿,看看我编辑的代码
标签: android