[英]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>
我有同样的问题,我解决了它引入一个HorizontalScrollView作为ScrollView的子项,然后tableLayout作为HorizontalScrollView的子项:
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? HorizontalScrollView能为您做任何事吗?
http://developer.android.com/reference/android/widget/HorizontalScrollView.html http://developer.android.com/reference/android/widget/HorizontalScrollView.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.