我们如何使表格布局滚动双向(水平,垂直)
我有一个XML文件中定义的表格,它目前设置为垂直滚动。但我也希望它根据需要水平滚动。我们如何使表格布局滚动双向(水平,垂直)
这里是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>
不HorizontalScrollView为你做些什么?
http://developer.android.com/reference/android/widget/HorizontalScrollView.html
也许某种布局(LinearLayout中,RelativeLayout的等)添加到您的XML的根源在哪里?
我有同样的问题,我解决它引入HorizontalScrollView为滚动型的孩子,然后tableLayout作为HorizontalScrollView的孩子:
这不是一个好的解决方案,因为用户不能同时以两种方式(垂直和水平)滚动。 – chteuchteu 2014-01-31 18:03:05
您可以检查此我制作的库:https://github.com/InQBarna/TableFixHeaders
它实现了一个可以通过Adapeter填充的表格。它也回收意见。
检查了这个代码,它很好。该项目很容易导入到Mac上的eclipse,但在windows上转移到eclipse是一件痛苦的事情。 [Linux的差距?]。这是一个反复出现的问题。 – 2013-03-24 10:58:56
哦,我现在看到这是2010 - 总之... – edwardsharp 2011-03-15 03:24:34