Xamarin之TableLayout部局

在Xamarin要实现一个能整齐摆放控件的layout,这时只有用TableLayout才实现。就象在网页中,用Table对齐控件是最方便的一样。

有几个相关属性,至关重要。比如我要设计一个表格,有三列,其中中间那列是放主要内容的,宽度要宽,另外二列宽度要短,那就要这样设计:

1. <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:stretchColumns="1">

这个属性设计第2列(中间列)为可伸展。

2.第1列和最后1列,设置一个较小的宽度:

 <TableRow>
            <TextView
                android:layout_width="100dip"
                android:layout_height="wrap_content"
                android:layout_weight="3"
                android:text="第1列"
                android:paddingLeft="10dip"
                android:layout_column="0" />

第3列放了一个线性部局,里面放了一个checkbox和一个按钮

<LinearLayout
                android:layout_column="2"
                android:layout_width="78dip">
                <CheckBox
                    android:layout_width="1dip"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:id="@+id/chkCHECK_CLEAR"
                    android:textAlignment="center"
                    android:gravity="center_horizontal"
                    android:layout_margin="0dip" />
                <Button
                    android:id="@+id/btnClear"
                    android:layout_width="1dip"
                    android:layout_height="35dip"
                    android:layout_weight="2"
                    android:gravity="center"
                    android:textColor="#F00"
                    android:textSize="10sp"
                    android:text="删除"
                    android:layout_gravity="fill_vertical" />
            </LinearLayout>

剩余的留给中间列(第2列)

这和网页中设计了固定宽度列,剩余的会自动分配给其它列类似。区别是Table_layout只有TableRow(等于TR),而没有显示地指定列(TD)。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值