开发者

How can I create this layout that spans multiple rows using Android TableLayout?

How would I go about creating the following layout using tablelayout? Column spanning is straightforward, but I haven't found开发者_开发知识库 any clear guidance on row spanning.

How can I create this layout that spans multiple rows using Android TableLayout?


try this one... You can use the layout_weight property to achieve what you are trying to do.. the below layout will have the layout as shown by you in the above picture..

<?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>

In the above code replace the view with the one that you want over there...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜