3

たくさんの例や投稿を見てみましたが、どれも私の問題に一致しません。

1つの画面に表示できないように、多くの列を持つ非常に長い(水平の)テーブルを作成する必要があります。そして、このようにテーブルを表示することが重要なので、テーブルをこぼしたくありません。

以下にXMLレイアウトを貼り付けました(主な重要なものを含む)

コードを削除すると、次のようになります。

android:fillViewport="true"

ホリゾンタルスクロールビューから、その中の私のテーブルは、特にその左側で、1つの場所に押し込まれます。このHorizo​​ntalScrollViewコンテナ領域の多くを使用することすらありません。

そして、このコードを使用すると、このHorizo​​ntalScrollViewは、テーブル全体をその中に表示します。列は、このスクロールビューに収まるようにスクイーズされます。

このスクロールビューに、画面の幅に収まるテーブルレイアウトのコンテンツのみを表示させたいので、残りの列をスクロールできます。しかし、今のところ、私はどこにも近づいていないようです。

では、どうすれば問題を解決できますか?私は何か間違ったことをしていますか?

これが私のXMLレイアウトです。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>

<HorizontalScrollView
    android:id="@+id/horizontalScrollView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scrollbars="horizontal"
    android:fillViewport="true">
    <TableLayout
        android:id="@+id/bot_scoreBoard"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/table_shape"
        android:orientation="horizontal"
        android:stretchColumns="*" >

        <TableRow
            android:layout_height="fill_parent"
            android:layout_margin="2dp"
            android:background="#ffffff"
            >
            <TextView
            />
               ....
            more than 16 columns of made using TextView
 ....
        </TableRow>
    </TableLayout>

</HorizontalScrollView>

</LinearLayout>
4

3 に答える 3

3

答えがわかりました。を使っていたからです。

 android:stretchColumns="*" 

テーブルレイアウトで。

さらに、列であった私の TextView は、単にではなく、特定の幅サイズに必要でした

android:layout_width="fill_parent" or "wrap_content"

それらが問題でした。

于 2012-12-03T20:25:56.863 に答える
2

でラップする必要がありTableLayoutますLinearLayout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<HorizontalScrollView
    android:id="@+id/horizontalScrollView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    android:scrollbars="horizontal" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

        <TableLayout
            android:id="@+id/bot_scoreBoard"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/table_shape"
            android:orientation="horizontal"
            android:stretchColumns="*" >

            <TableRow
                android:layout_height="fill_parent"
                android:layout_margin="2dp"
                android:background="#ffffff" >

                <TextView />
           ....
        more than 16 columns of made using TextView
     ....
            </TableRow>
        </TableLayout>
    </LinearLayout>
</HorizontalScrollView>

于 2012-12-03T01:24:29.373 に答える