【问题标题】:Horizontal scroll required(Android)需要水平滚动(Android)
【发布时间】:2011-01-26 07:39:28
【问题描述】:

我有一个在 ScrollView 中的 TableLayout,所以我得到了垂直滚动。但是当列超过屏幕时,我也想要水平滚动。

我该怎么做?请帮忙。

谢谢, 法哈

【问题讨论】:

标签: android


【解决方案1】:

看看这个,它可能是你想要的。

    <ScrollView 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <HorizontalScrollView
            android:layout_width="fill_parent"          
            android:layout_height="fill_parent" >

                <TableLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent">

                    <TableRow 
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent">
                        <ImageView android:src="@drawable/icon"/>
                        <ImageView android:src="@drawable/tube"/>
                    </TableRow>

                    <TableRow ....
                    </TableRow>

                    <TableRow ....
                    </TableRow>

               </TableLayout>

       </HorizontalScrollView>

    </ScrollView>

【讨论】:

    【解决方案2】:

    我想试试:

    android:scrollbars="horizontal"
    

    在您的视图的 xml 定义中,但是如果您使用的是滚动视图,它不支持水平滚动,因此不会显示栏...

    【讨论】:

    【解决方案3】:

    将属性放入滚动视图标签中。

    android:scrollbars="horizontal"
    

    【讨论】:

    • 我觉得scrollview不支持水平滚动条,看这里groups.google.com/group/android-developers/browse_thread/thread/…
    • 如果您需要访问两个滚动条,请在其之间使用管道(|)。 android:scrollbars="horizo​​ntal|vertical"
    • 是的,这种方法不起作用。正如我之前所说,scrollview 不支持水平滚动。如果你不想设置水平滚动,你需要使用 Horizo​​ntalScroll 视图,但是你没有同时垂直滚动。
    【解决方案4】:

    【讨论】:

      【解决方案5】:

      如上所述,将 Horizo​​ntalScrollView 放置在 ScrollView 内。 这是有关如何做到这一点的教程: http://androiddevblog.blogspot.com/2009/12/creating-two-dimensions-scroll-view.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-05-06
        • 2020-07-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-16
        • 1970-01-01
        相关资源
        最近更新 更多