如果屏幕太长,则使水平RadioButton换行 [英] Have horizontal RadioButtons wrap if too long for screen

查看:334
本文介绍了如果屏幕太长,则使水平RadioButton换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有以下单选按钮.我想让它们像这样显示:

So I have the following radiobuttons. I want to have them display like this:

但是发生这种情况:

如何使它像上面一样显示?
我可以在Eclipse的GUI编辑器中移动它,但是它从RadioGroup中删除了RadioButton!
在该组中,它忽略了所有其他布局参数.

How I can get it to display like above?
I can move in the GUI editor in Eclipse it but it removes the RadioButton from the RadioGroup!
Within the group, it ignores all other layout parameters.

<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>

推荐答案

您可以简单地复制此类:

You can simply copy this class:

放入项目中的适当程序包,并以XML实例化,如下所示:

into an appropriate package in your project and instantiate in XML like so:

<view
    class="mypackage.packagepath.MultiLineRadioGroup"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"/>

这篇关于如果屏幕太长,则使水平RadioButton换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆