开发者

Why is my horizontal LinearLayout not reserving enough height for its contents?

I am working on an application that displays information about countries of the world (I'm learning with something real and I already have this data). Part of my layout is a LinearLayout which contains the country's flag and some basic information. There are five rows of information in the table to the right of the flag. The trouble is the LinearLayout is only using the height of the flag for it total height. Most flags are 2.5 rows high so some of my information is cut off. Why isn't the LiniearLayout's height the largest of its two elements? Any suggestions for what I can do to make this work?

Here is the definition of the LinearLayout in question:

        <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_a开发者_C百科rea_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>

I tried reversing the table and the image view so the flag was on the right and the information on the left. I was hoping that the height of the LiniearLayout would now be the height of the information table. No luck it was still the height of the flag.

Any help would be appreciated.

Thanks,

Ian


Try android:layout_height="wrap_content" for your TableLayout.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜