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

Ami*_*mit 5 android android-widget

我有一个在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>
Run Code Online (Sandbox Code Playgroud)

Nem*_*sis 8

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


edw*_*arp -1

Horizo​​ntalScrollView 能为您做些什么吗?

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

也许将某种布局(LinearLayout、Relativelayout 等)添加到 xml 的根目录中?