您的位置:首页 > 其它

TableLayout实现均匀布局(条目横向1:1排列)

2016-04-05 10:49 204 查看
像下面的布局效果,我们经常使用LinearLayout实现,其实也可以使用TableLayout去简单的实现



代码如下:

<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/spacing_small"
android:stretchColumns="*">

<TableRow>

<TextView
style="@style/GrayText"
android:layout_width="1dp"
android:text="订单号" />

<TextView
style="@style/GrayText"
android:layout_width="1dp"
android:text="预定时间" />
</TableRow>

<TableRow android:layout_marginTop="@dimen/spacing_tiny">

<TextView
android:id="@+id/order_num"
style="@style/BlackText"
android:layout_width="1dp"
android:text="201687" />

<TextView
android:id="@+id/time"
style="@style/Bl
4000
ackText"
android:layout_width="1dp"
android:text="2016年3月24日" />
</TableRow>

<TableRow android:layout_marginTop="@dimen/spacing_normal">

<TextView
style="@style/GrayText"
android:layout_width="1dp"
android:text="出行目的" />

<TextView
style="@style/GrayText"
android:layout_width="1dp"
android:text="订单状态" />
</TableRow>

<TableRow android:layout_marginTop="@dimen/spacing_tiny">

<TextView
android:id="@+id/aim"
style="@style/BlackText"
android:layout_width="1dp"
android:text="商务谈判" />

<TextView
android:id="@+id/order_status"
style="@style/BlueText"
android:layout_width="1dp"
android:text="出票中" />
</TableRow>
</TableLayout>


这里有几个属性需要设置:

android:stretchColumns=”*”

TableRow里面的子view宽度统一设置成一个固定值如1dp
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: