【发布时间】:2026-01-30 14:40:01
【问题描述】:
如何使用 tablelayout 创建以下布局?列跨越很简单,但我没有找到任何关于行跨越的明确指导。
【问题讨论】:
标签: android tablelayout
如何使用 tablelayout 创建以下布局?列跨越很简单,但我没有找到任何关于行跨越的明确指导。
【问题讨论】:
标签: android tablelayout
试试这个...您可以使用 layout_weight 属性来实现您想要做的事情.. 下面的布局将具有您在上图中显示的布局..
<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow>
<TableLayout android:layout_width="0dip"
android:layout_weight="2" android:layout_height="fill_parent">
<TableRow android:layout_width="0dip" android:layout_weight="2"
android:layout_height="0dip">
<View android:layout_width="0dip" android:layout_weight="1"
android:layout_margin="5dip" android:layout_height="fill_parent"
android:background="#fff"></View>
<View android:layout_width="0dip" android:layout_weight="1"
android:background="#eee" android:layout_margin="5dip"
android:layout_height="fill_parent"></View>
</TableRow>
<TableRow android:layout_width="0dip" android:layout_weight="2"
android:layout_height="0dip">
<View android:layout_width="0dip" android:layout_weight="1"
android:background="#eee" android:layout_height="fill_parent"
android:layout_margin="5dip"></View>
<View android:layout_width="0dip" android:layout_weight="1"
android:layout_margin="5dip" android:layout_height="fill_parent"
android:background="#fff"></View>
</TableRow>
</TableLayout>
<TableLayout android:layout_width="0dip"
android:layout_weight="1" android:layout_height="fill_parent">
<TableRow>
<View android:layout_width="0dip" android:layout_weight="1"
android:background="#bbb" android:layout_height="fill_parent"></View>
</TableRow>
</TableLayout>
</TableRow>
在上面的代码中,将视图替换为您想要的视图...
【讨论】: