【问题标题】:Use ScrollView & HorizontalScrollView in TableLayout在 TableLayout 中使用 ScrollView 和 Horizo​​ntalScrollView
【发布时间】:2011-08-30 07:25:47
【问题描述】:

如何垂直和水平设置ScrollView?我尝试使用下面的代码,但没有成功。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scrollbarFadeDuration="1000"
        android:scrollbarSize="12dip"
        android:background="@color/red" >

        <HorizontalScrollView android:id="@+id/horizontalScrollView1" android:layout_width="wrap_content" android:layout_height="wrap_content">
            <TableLayout android:layout_width="match_parent"  android:layout_marginTop="10dp" android:id="@+id/tableLayout1" android:layout_height="wrap_content" android:stretchColumns="1" android:collapseColumns="2">

            </TableLayout>
        </HorizontalScrollView>
</ScrollView>

这是我的全部代码:http://pastebin.com/ysRhLMyt

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    试试,

    设置android:scrollbarFadeDuration="0"

           OR 
    

    ScrollView1.setScrollbarFadingEnabled(false);

           OR
    

    android:scrollbarFadeDuration="0" 和

    android:scrollbarAlwaysDrawVerticalTrack="true" 表示垂直

    android:scrollbarAlwaysDrawHorizo​​ntalTrack="true" 表示水平

    还有一件事,

    请记住,ScrollView 只能有一个子控件,因此我们可以将容器(Linear、relative、Table Layouts)作为 ScrollView 的子控件,并将所有控件放在该子控件中。

    供参考:http://android-pro.blogspot.com/2010/02/android-scrollview.html

    TableLayout ScrollView Vertical & Horizontal

    【讨论】:

      【解决方案2】:

      尝试将ScrollView 的高度更改为"fill_parent"

      【讨论】:

        【解决方案3】:

        如果是你想要水平移动的行,那么我建议你设计你的布局像

        Scrollview作为父级,table layout作为唯一子级,然后将table rows添加到table layout中,将horizo​​ntalscrollview放在每个table row里面。这样,您可以垂直移动表格并水平移动表格中的行。

        希望这会有所帮助。

        【讨论】:

        • 根据您的建议,它会在每一行显示水平滚动条吗?是吗?
        • 是的,如果不需要,您可以随时禁用滚动条。
        【解决方案4】:

        线性布局(@+id/linearLayout3)方向是水平的,让它垂直,这样内容就显示在下面。我认为目前,您的列表分隔符和列表项是在屏幕上水平添加的,而不是垂直添加的。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-08-31
          • 1970-01-01
          • 1970-01-01
          • 2015-04-27
          • 1970-01-01
          相关资源
          最近更新 更多