【发布时间】:2010-11-14 14:54:52
【问题描述】:
我正在开发一个显示世界各国信息的应用程序(我正在学习一些真实的东西,并且我已经有了这些数据)。我的部分布局是一个包含国家国旗和一些基本信息的 LinearLayout。标志右侧的表格中有五行信息。问题是 LinearLayout 只使用标志的高度作为它的总高度。大多数标志都是 2.5 行高,所以我的一些信息被切断了。为什么 LiniearLayout 的高度不是它的两个元素中最大的?关于我可以做些什么来完成这项工作的任何建议?
这是有问题的 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 的高度现在是信息表的高度。不幸的是,它仍然是国旗的高度。
任何帮助将不胜感激。
谢谢,
伊恩
【问题讨论】:
标签: android android-layout android-linearlayout