android使一个单选按钮可滚动

时间:2012-07-11 22:03:33

标签: android radio-button scrollbar

我有一个相当大的单选按钮文本的问题。这些单选按钮的文本是动态生成的。不幸的是,有时会分配文本,这会推动我的布局中的其他对象。我虽然如果我可以使单选按钮可滚动,那么这将删除此问题。我的意思是可滚动的是,如果文本长度超出一定大小,单选按钮侧面的滚动条会出现,这样用户就可以滚动单选按钮的文本,而不会改变我的xml文件的其余部分的布局。当我的意思是改变布局时,其他小部件被进一步向下推,例如按钮。这是单选按钮的xml布局文件布局。

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="217dp"
        android:orientation="vertical" >

        <RadioGroup
            android:id="@+id/radioGroup1"
            android:layout_width="match_parent"
            android:layout_height="212dp"
            android:layout_weight="6.86" >

           <ScrollView
               android:id="@+id/ScrlView"
               android:layout_width="fill_parent"
               android:layout_height="78dp" >

            <RadioButton
                android:id="@+id/radio1"
                android:layout_width="match_parent"
                android:layout_height="79dp"
                android:checked="true"
                android:text="RadioButton"
                android:textSize="16dp" />
             </ScrollView>
            <ScrollView
                android:id="@+id/ScrlView"
                android:layout_width="fill_parent"
                android:layout_height="74dp" >

            <RadioButton
                android:id="@+id/radio2"
                android:layout_width="304dp"
                android:layout_height="75dp"
                android:text="RadioButton" />
              </ScrollView>

               <ScrollView android:id="@+id/ScrlView" android:layout_width="fill_parent" android:layout_height="fill_parent" >
            <RadioButton
                android:id="@+id/radio3"
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:text="RadioButton" />
            </ScrollView>

        </RadioGroup>
    </LinearLayout>

我检查了这个链接,虽然我可能会尝试为收音机组添加滚动视图,因此如果收音机问题太长,用户可以向下滚动。 How to vertical scroll an activity in Android

1 个答案:

答案 0 :(得分:0)

尝试使用TableLayout并告诉我们你得到了什么。将每个单选按钮放在自己的表格行中。您还应该知道setText()也应该接受SpannableStringBuilder作为输入。这可以让您更好地控制文本的格式。最后,我认为你需要考虑一下设计。我的意思是有限制!如果你得到太多的文字,也许你没有展示所有的文字。看看在线报纸。他们有同样的问题。无法一直显示所有内容。