The*_*ngK 11 android android-layout
所以我有以下radiobuttons.我想让它们显示如下:

然而,这发生:

我怎么能让它像上面那样展示?
我可以在Eclipse中的GUI编辑器中移动它但它从RadioGroup中移除了RadioButton!
在组内,它忽略所有其他布局参数.
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/timeBar"
android:layout_marginTop="43dp"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/privRadio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Everyone" />
<RadioButton
android:id="@+id/privRadio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="FriendOfFriends" />
<RadioButton
android:id="@+id/privRadio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Friends" />
</RadioGroup>
Run Code Online (Sandbox Code Playgroud)
您只需复制此类:
进入项目中的适当包并以XML形式实例化:
<view
class="mypackage.packagepath.MultiLineRadioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"/>
Run Code Online (Sandbox Code Playgroud)
您要求的是FlowLayout。与 0gravity 更“静态”的解决方案相反,这种布局的优点是仅在需要时进行包装。