我试着看了大量的例子和帖子,但没有一个符合我的问题。
我需要做一个很长的(水平的)表格,有很多列,所以不可能在一个屏幕上显示。我不想把桌子弄翻,因为用这种方式展示桌子很重要。
我在下面粘贴了XML布局(包括主要的重要布局)
问题是如果我删除代码:

android:fillViewport="true"

从水平滚动视图,然后我的桌子在它里面,被挤在一个地方,特别是在它的左边。它甚至不太使用这个水平滚动视图容器区域。
及,
如果我使用这段代码,那么这个水平滚动视图会在其中显示我的整个表-列被挤压以确保它们适合这个滚动视图。
我只希望这个scrollview只显示我的tablelayout中适合屏幕宽度的内容,这样我就可以滚动剩下的列。但现在,我好像一点也不靠近。
那么我该如何解决我的问题呢?我做错什么了吗?
这里还有我的xml布局。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>

<HorizontalScrollView
    android:id="@+id/horizontalScrollView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scrollbars="horizontal"
    android:fillViewport="true">
    <TableLayout
        android:id="@+id/bot_scoreBoard"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/table_shape"
        android:orientation="horizontal"
        android:stretchColumns="*" >

        <TableRow
            android:layout_height="fill_parent"
            android:layout_margin="2dp"
            android:background="#ffffff"
            >
            <TextView
            />
               ....
            more than 16 columns of made using TextView
 ....
        </TableRow>
    </TableLayout>

</HorizontalScrollView>

</LinearLayout>

最佳答案

我得到了答案。因为我用的是

 android:stretchColumns="*"

在TableLayout中。
加上我的文本视图,这是列,需要一些特定的宽度大小,而不是仅仅
android:layout_width="fill_parent" or "wrap_content"

这些就是问题所在。

10-07 18:58
查看更多