5

我有一个定义了 3 列的表格布局。但是由于第二列中的文本很大,因此内容会显示在屏幕之外。所以我试图放置一个水平滚动条。却无能为力。

我使用 Android 1.5 作为目标。

表格布局的 XML 代码

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

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


    <TableLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:stretchColumns="0,1,2"
        android:id="@+id/tLayout"
        android:scrollbars="horizontal"

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

1 回答 1

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

    <HorizontalScrollView 
        android:layout_width="320px" android:layout_height="fill_parent">

        <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/linlay" android:layout_width="320px"
            android:layout_height="fill_parent" android:stretchColumns="1"
            android:background="#000000"/>

    </HorizontalScrollView>

</ScrollView>
于 2018-05-22T07:29:54.317 回答