简体   繁体   English

我们怎样才能使表格布局双向滚动(水平,垂直)

[英]how can we make table layout to scroll both ways ( horizontally, vertically)

I am having a table defined in XML file, which currently set to Scroll vertically. 我有一个在XML文件中定义的表,当前设置为垂直滚动。 But i also want it scroll horizontally as required. 但我也希望它根据需要水平滚动。

Here is the code of XML in use 这是使用中的XML代码

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

我有同样的问题,我解决了它引入一个Horizo​​ntalScrollView作为ScrollView的子项,然后tableLayout作为Horizo​​ntalScrollView的子项:

You can check this library that I made: https://github.com/InQBarna/TableFixHeaders 您可以查看我创建的这个库: https//github.com/InQBarna/TableFixHeaders

It Implements a table that can be filled through an Adapeter. 它实现了一个可以通过Adapeter填充的表。 It also recycles views. 它还回收了观点。

Does HorizontalScrollView do anything for you? Horizo​​ntalScrollView能为您做任何事吗?

http://developer.android.com/reference/android/widget/HorizontalScrollView.html http://developer.android.com/reference/android/widget/Horizo​​ntalScrollView.html

Perhaps add some kind of layout (LinearLayout, Relativelayout, etc.) to the root of your xml? 也许在xml的根目录中添加某种布局(LinearLayout,Relativelayout等)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让我的布局水平和垂直滚动? - How can I make my layout scroll both horizontally and vertically? 如何使布局水平和垂直滚动? - How to make layout scrollable both horizontally and vertically? 如何使相对布局垂直/水平滚动? - How to make relative layout scroll vertically/horizontally? 如何水平和垂直滚动此布局 - How to scroll horizontally and vertically this layout Scrollview在android中水平和垂直滚动表格 - Scrollview to scroll table both horizontally and vertically in android 如何在Android中水平和垂直滚动ViewPager? - How to scroll ViewPager both horizontally and vertically in Android? 水平和垂直滚动。 如何在代码视图中显示Java代码并水平和垂直滚动代码? - Scrolling Both horizontally and vertically . how can i show my java code in a code view and scroll my code both horizontally and vertically? 如何使桌面布局垂直和水平滚动 - How to make a tablelayout scroll vertically and horizontally 你能做一个允许水平和垂直滚动的recyclerview吗 - Can you make a recyclerview that allows scrolling both horizontally and vertically 如何在android中使网格视图水平滚动而不是垂直滚动? - How to make grid view scroll horizontally not vertically in android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM