【问题标题】:How do I remove the extra pixels at the top of a ScrollView?如何删除 ScrollView 顶部的多余像素?
【发布时间】:2013-05-14 01:41:34
【问题描述】:

我一直在开发一个应用程序,该应用程序允许您创建真值表并将其保存为 HTML 以便在 word 中使用。我的应用程序运行良好,但我正在尝试对其进行清理。我有以下布局代码,可让您滚动表格,同时仍将名称行保持在顶部:

    <RelativeLayout
        android:id="@+id/RelLayout"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent" >

        <TableLayout
            android:id="@+id/nameTable"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="1dp" >

            <TableRow
                android:id="@+id/nameRow"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </TableLayout>

        <ScrollView
            android:id="@+id/scrollView1"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:scrollbarStyle="insideOverlay"
            android:scrollbars="vertical" >

            <TableLayout
                android:id="@+id/TruthTableLayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="1dp"
                android:background="#000000" >
            </TableLayout>
        </ScrollView>
    </RelativeLayout>
</HorizontalScrollView>

这对我来说总体上很好,但是当我滚动表格时它不会立即消失,而是在名称行上方显示几个像素。所以我的问题是如何让这些像素消失?

因为我没有发布图片的声誉,这里是我正在谈论的屏幕截图的链接。 http://i.imgur.com/4KWc32O.png

【问题讨论】:

    标签: java android layout scrollview pixels


    【解决方案1】:

    首先你的利润在这里:

       <TableLayout
            android:id="@+id/nameTable"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="1dp" >
    

    顶部应该是 0。所以如果你需要边距,它应该是:

       <TableLayout
            android:id="@+id/nameTable"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="1dp"
            android:layout_marginLeft="1dp" >
    

    【讨论】:

    • 呸,我没想到!我很快就会回家测试它。
    • 经过测试,效果很好。不敢相信我没有看到,我已经被困了好几天了。我会投票,但我还没有代表这样做。
    • 别担心,我很乐意提供帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-28
    • 2011-06-06
    • 2016-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-07
    相关资源
    最近更新 更多