前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >TableLayout实现均匀布局(条目横向1:1排列)

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

作者头像
夏洛克的猫
发布2018-10-18 14:21:33
1.1K0
发布2018-10-18 14:21:33
举报
文章被收录于专栏:移动开发移动开发

像下面的布局效果,我们经常使用LinearLayout实现,其实也可以使用TableLayout去简单的实现

这里写图片描述
这里写图片描述

代码如下:

代码语言:javascript
复制
                <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/BlackText"
                            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

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016年04月05日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档