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

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

问题描述

我试图寻找numerious例子和职位,但他们没有我的问题相匹配。

我需要一个很长的(水平)表的列,因此不可能在一个屏幕来显示。我不想泻表,因为它是我用这种方式显示我的表是非常重要的。

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

问题是,如果我删除code:

 的android:fillViewport =真

Horizo​​ntalScrollView ,然后我里面的表,被挤压在一个地方,尤其是在它的左侧。它甚至没有使用太多这Horizo​​ntalScrollView容器的区域。

和,
如果我用这个code,那么这Horizo​​ntalScrollView显示了我的整个表里面 - 列是挤压以确保它们适合在这个滚动视图

我只想这个滚动视图只显示适合屏幕宽度我tablelayout的内容,这样我就可以滚动剩余的列。但是现在,我似乎并没有取得任何进展近了。

那么,如何解决我的问题?难道我做错了什么?

另外这里是我的XML布局。

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
>< Horizo​​ntalScrollView
    机器人:ID =@ + ID / horizo​​ntalScrollView
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:滚动条=水平
    机器人:fillViewport =真正的>
    < TableLayout
        机器人:ID =@ + ID / bot_scoreBoard
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:背景=@绘制/ table_shape
        机器人:方向=横向
        机器人:stretchColumns =*>        <的TableRow
            机器人:layout_height =FILL_PARENT
            机器人:layout_margin =2DP
            机器人:背景=#FFFFFF
            >
            <的TextView
            />
               ....
            使用TextView中取得的超过16列
 ....
        < /&的TableRow GT;
    < / TableLayout>< / Horizo​​ntalScrollView>< / LinearLayout中>


解决方案

我得到了答案。这是因为我使用

 的android:stretchColumns =*

在TableLayout。

再加上我的TextView这是列,需要一些特定的宽度尺寸,而不仅仅是

 的android:layout_width =FILL_PARENT或WRAP_CONTENT

这些都是问题。

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.

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

The thing is if I remove the code:

android:fillViewport="true"

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.

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 ?

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="*" 

in the TableLayout.

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

android:layout_width="fill_parent" or "wrap_content"

Those were the problems.

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

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