3

テーブルを動的に作成するアクティビティがあります。アクティビティが作成され、正常に動作しています。

これは、xml ファイルのソース コードです。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#142c57"
    tools:context=".TableActivity" >

    <TextView
        android:id="@+id/heading_textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:text="@string/followup_list" 
        android:textColor="#FFFFFF"
        android:textSize="15sp"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/heading_textView"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp" 
        android:padding="3dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true" 
            android:background="@drawable/inner_box">

            <ScrollView
                android:id="@+id/scrollView1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true" >

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" >

                    <HorizontalScrollView
                        android:id="@+id/horizontalScrollView1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentTop="true" >

                        <TableLayout
                            android:id="@+id/follow_up_table"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent" 
                            android:stretchColumns="0">


                        </TableLayout>

                    </HorizontalScrollView>

                </RelativeLayout>

            </ScrollView>

        </RelativeLayout>

    </RelativeLayout>

</RelativeLayout>

xml ファイルの出力:

出力

ボックス全体をテーブルで埋めたいのですが、テーブルの右側のスペースは不要で、ぎこちなく見えます。これを達成するために何をする必要がありますか?

4

5 に答える 5

3

画面に合わせてすべての列を拡大および縮小することをお勧めします。

<TableLayout
 android:id="@+id/follow_up_table"
 android:layout_width="match_parent"
 android:layout_height="match_parent" 
 android:stretchColumns="*"
 android:shrinkColumns="*">

</TableLayout>
于 2013-12-16T01:37:51.400 に答える
1

レイアウトは次のように編集する必要がありました

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#142c57"
    tools:context=".TableActivity" >

    <TextView
        android:id="@+id/heading_textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:text="@string/followup_list" 
        android:textColor="#FFFFFF"
        android:textSize="15sp"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/heading_textView"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp" 
        android:padding="3dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true" 
            android:background="@drawable/inner_box">

            <ScrollView
                android:id="@+id/scrollView1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true" >

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" >

                    <TableLayout
                        android:id="@+id/follow_up_table"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentTop="true" 
                        android:stretchColumns="0,1">


                    </TableLayout>

                </RelativeLayout>

            </ScrollView>

        </RelativeLayout>

    </RelativeLayout>

</RelativeLayout>

出力: _

出力

于 2013-04-24T12:58:34.770 に答える
1

テーブル レイアウトの幅はコンテンツをラップします。match_parent

<TableLayout
 android:id="@+id/follow_up_table"
 android:layout_width="match_parent"
 android:layout_height="match_parent" 
 android:stretchColumns="0">


</TableLayout>
于 2013-04-24T12:40:16.653 に答える