1

私は世界の国に関する情報を表示するアプリケーションに取り組んでいます (私は実際のもので学習しており、すでにこのデータを持っています)。私のレイアウトの一部は、国の旗といくつかの基本情報を含む LinearLayout です。表のフラグの右側に 5 行の情報があります。問題は、 LinearLayout がフラグの高さだけを使用して高さを合計していることです。ほとんどのフラグは 2.5 行の高さなので、情報の一部が切り取られています。LiniearLayout の高さが 2 つの要素の中で最大でないのはなぜですか? これを機能させるために何ができるかについて何か提案はありますか?

問題の LinearLayout の定義は次のとおりです。

        <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
        <ImageView
            android:id="@+id/flag"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:src="@drawable/noflag" />
        <TableLayout
            android:id="@+id/info1"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_marginLeft="10dip">
            <TableRow>
                <TextView
                    android:id="@+id/capitallabel"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/capital_label"
                    style="?infoLabel"/>
                <TextView
                    android:id="@+id/capitalvalue"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="4dip"
                    style="?infoValue"/>
            </TableRow>
            <TableRow>
                <TextView
                    android:id="@+id/capitaltimelabel"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/capital_time_label"
                    style="?infoLabel"/>
                <TextView
                    android:id="@+id/capitaltimevalue"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="4dip"
                    style="?infoValue"/>
            </TableRow>
            <TableRow>
                <TextView
                    android:id="@+id/landarealabel"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/land_area_label"
                    style="?infoLabel"/>
                <TextView
                    android:id="@+id/landareavalue"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="4dip"
                    style="?infoValue"/>
            </TableRow>
            <TableRow>
                <TextView
                    android:id="@+id/waterarealabel"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/water_area_label"
                    style="?infoLabel"/>
                <TextView
                    android:id="@+id/waterareavalue"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="4dip"
                    style="?infoValue"/>
            </TableRow>
            <TableRow>
                <TextView
                    android:id="@+id/coastlinelabel"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/coast_line_label"
                    style="?infoLabel"/>
                <TextView
                    android:id="@+id/coastlinevalue"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="4dip"
                    style="?infoValue"/>
            </TableRow>
        </TableLayout>
    </LinearLayout>

表と画像ビューを逆にして、フラグが右側に、情報が左側に表示されるようにしました。LiniearLayout の高さが情報テーブルの高さになることを期待していました。幸運なことに、それはまだ旗の高さでした。

どんな助けでも大歓迎です。

ありがとう、

イアン

4

1 に答える 1

1

あなたのために試してみandroid:layout_height="wrap_content"てくださいTableLayout

于 2010-11-14T16:09:35.043 に答える