怎么才能让表格布局滚动两种方式(水平,垂直) [英] how can we make table layout to scroll both ways ( horizontally, vertically)

查看:130
本文介绍了怎么才能让表格布局滚动两种方式(水平,垂直)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在XML文件中,目前设置为垂直滚动定义的表。但我也希望它需要水平滚动。

下面是XML的使用code

 < XML版本=1.0编码=UTF-8&GT?;

<滚动型的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
     机器人:滚动条=垂直
     机器人:layout_height =FILL_PARENT
     机器人:layout_width =FILL_PARENT>

    < TableLayout
        的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:stretchColumns =0,1,2
        机器人:ID =@ + ID / tLayout
        机器人:滚动条=垂直
        >
        <的TableRow
            机器人:layout_width =FILL_PARENT>
            <的TextView
                机器人:填充=3dip
                机器人:重力=左
                机器人:文本=名称
                />
            <的TextView
                机器人:填充=3dip
                机器人:重力=左
                机器人:文本=地址
                />
            <的TextView
                机器人:填充=3dip
                机器人:重力=左
                机器人:文本=时代
                />
        < /的TableRow>
    < / TableLayout>
< /滚动型>
 

解决方案

我有同样的问题,我解决了它引入Horizo​​ntalScrollView为滚动型的孩子,然后tableLayout作为Horizo​​ntalScrollView的孩子:

                           

I am having a table defined in XML file, which currently set to Scroll vertically. But i also want it scroll horizontally as required.

Here is the code of XML in use

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:scrollbars="vertical" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent">

    <TableLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:stretchColumns="0,1,2"
        android:id="@+id/tLayout"
        android:scrollbars="vertical"
        >   
        <TableRow
            android:layout_width="fill_parent">
            <TextView
                android:padding="3dip"
                android:gravity="left"
                android:text="Name"
                />
            <TextView
                android:padding="3dip"
                android:gravity="left"
                android:text="Address"
                />
            <TextView
                android:padding="3dip"
                android:gravity="left"
                android:text="Age"
                />
        </TableRow>
    </TableLayout>
</ScrollView>

解决方案

I had the same problem and I solved it introducing a HorizontalScrollView as a child of the ScrollView and then the tableLayout as a child of the HorizontalScrollView:

这篇关于怎么才能让表格布局滚动两种方式(水平,垂直)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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