【问题标题】:HorizontalScrollView inside TableRowTableRow 内的 Horizo​​ntalScrollView
【发布时间】:2017-04-06 16:42:06
【问题描述】:

我在 TableLayout 中有一个 TableRow。如果我在 TableRow 中放置一个垂直 ScrollView,它会按预期工作。但是,如果我在 TableRow 中放置一个 Horizo​​ntalScrollView,则滚动根本不起作用。

有人知道为什么会这样吗?我可以使用任何解决方法来实现吗?

提前致谢!

--编辑--

这是一个例子:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TableRow>
        <HorizontalScrollView android:scrollbars="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

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

                <TableRow>
                    <Button android:layout_width="350px" android:layout_height="350px" android:text="TEST" />
                    <Button android:layout_width="350px" android:layout_height="350px" android:text="TEST" />
                </TableRow>
                <TableRow>
                    <Button android:layout_width="350px" android:layout_height="350px" android:text="TEST" />
                    <Button android:layout_width="350px" android:layout_height="350px" android:text="TEST" />
                </TableRow>
            </TableLayout>

        </HorizontalScrollView>

    </TableRow>

</TableLayout>

如果我将 Horizo​​ntalScrollView 更改为垂直 ScrollView,它可以工作(显然是垂直的)。

【问题讨论】:

  • 发布您的布局 xml 和相关的 Java。

标签: android scrollbar tablelayout tablerow horizontalscrollview


【解决方案1】:

试试

<HorizontalScrollView android:scrollbars="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent">

编辑:

这应该将 ScrollView 设置为内容的大小(内容大小),而不是父级中可用位置的大小。

【讨论】:

  • 欢迎来到 StackOverflow。您可能想为您的答案添加更多解释(为什么这可以解决问题等),或者至少在您未来的答案中记住这一点......
猜你喜欢
  • 2014-07-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-02
  • 2021-01-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多