如何以正确的方式在水平滚动视图中放置一个很长的表格布局? [英] How to put a very long table layout inside the horizontal Scroll view in the CORRECT way?

查看:35
本文介绍了如何以正确的方式在水平滚动视图中放置一个很长的表格布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试查看大量示例和帖子,但没有一个与我的问题相符.

I tried looking at numerious examples and posts but none of them matches my problem.

我需要制作一个非常长(水平)的表格,其中包含许多列,因此无法在单个屏幕中显示.而且我不想弄翻桌子,因为以这种方式展示我的桌子很重要.

I need to make a very long (horizontal) table with many columns so it is impossible to display in a single screen. And I don't want to spilt the table because it is important that I display my table in this way.

我在下面粘贴了我的 XML 布局(包括主要的重要布局)

I have pasted my XML layout below (including the main important ones)

问题是如果我删除代码:

The thing is if I remove the code:

android:fillViewport="true"

Horizo​​ntalScrollView 然后我在里面的桌子被挤压在一个地方,特别是在它的左侧.它甚至没有使用多少这个 Horizo​​ntalScrollView 容器区域.

from the HorizontalScrollView then my table inside it, gets squeezed in one place, especially at the left side of it. It doesn't even use much of this HorizontalScrollView container area.

而且,如果我使用此代码,则此 Horizo​​ntalScrollView 会在其中显示我的整个表格 - 挤压列以确保它们适合此滚动视图.

And, If I use this code, then this HorizontalScrollView shows my whole table inside it - the columns are squeeze to make sure they fit in this scrollview.

我只想让这个滚动视图只显示适合屏幕宽度的表格布局的内容,这样我就可以滚动剩余的列.但现在,我似乎没有任何内容近.

I just want this scrollview to display only the content of my tablelayout that fits in the screen width, so I can scroll the remaining columns. But right now, I don't seem to get anywhere near.

那么我该如何解决我的问题呢?我做错了什么吗?

So how do I solve my problem? Am I doing something wrong ?

这里也是我的 XML 布局.

Also here is my XML layout.

<?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>

推荐答案

我得到了答案.那是因为我正在使用

I got the answer. It was because I was using the

 android:stretchColumns="*" 

在表格布局中.

加上我的 TextView 列,需要一些特定的宽度大小而不仅仅是

Plus my TextView which were the columns, needed to some specific width size rather than just

android:layout_width="fill_parent" or "wrap_content"

这些就是问题所在.

这篇关于如何以正确的方式在水平滚动视图中放置一个很长的表格布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆