Android表格布局本身没有边框,不过可以通过背景色的设置可以实现表格边框的显示。

首先可以设置TableRow的背景色,然后设置内容的背景色。根据它们的颜色差就出现了边框。只要微调Content与TableRow的margin和pading属性就可以了!

调的过程真是烦人!下次不做这种工作了~呜呜!难受!

贴上布局代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white" > <include layout="@layout/titlebar_home" /> <TableLayout
android:id="@+id/table1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:padding="6.5dip" > <TableRow
android:background="@color/jiemianbiankuang"
android:orientation="horizontal"
android:paddingLeft="0.5dip"
android:paddingRight="0.5dip"
android:paddingTop="1dip" > <ImageButton
android:id="@+id/imageViewMSG"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="0.5dip"
android:layout_marginLeft="0.5dip"
android:background="@color/white"
android:contentDescription="@string/messagecenter"
android:src="@drawable/msg" /> <ImageButton
android:id="@+id/imageView1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="0.5dip"
android:layout_marginLeft="0.5dip"
android:background="@color/white"
android:src="@drawable/book" /> <ImageButton
android:id="@+id/imageView2"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="0.5dip"
android:layout_marginLeft="0.5dip"
android:background="@color/white"
android:src="@drawable/maozi" />
</TableRow> <TableRow
android:background="@color/jiemianbiankuang"
android:orientation="horizontal"
android:paddingLeft="0.5dip"
android:paddingRight="0.5dip"
android:paddingTop="0dip" > <ImageButton
android:id="@+id/imageView4"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="0.5dip"
android:layout_marginLeft="0.5dip"
android:background="@color/white"
android:src="@drawable/earth" /> <ImageButton
android:id="@+id/imageView5"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="0.5dip"
android:layout_marginLeft="0.5dip"
android:background="@color/white"
android:src="@drawable/unno" /> <ImageButton
android:id="@+id/imageView6"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="0.5dip"
android:layout_marginLeft="0.5dip"
android:background="@color/white"
android:src="@drawable/zuoye" />
</TableRow>
</TableLayout> </RelativeLayout>

界面效果图

Android表格布局之设置边框的更多相关文章

  1. Android表格布局(Table Layout)

    Android表格布局(Table Layout) 先来看布局管理器之间继承关系图: 图1 可知TableLayout继承了LinearLayout,所以表格布局本质上依然是线性管理器. 表格布局采用 ...

  2. Android 表格布局<TableLayout>

    表格布局即,tableLayout,表格布局通过行.列的形式来管理UI组件,TablelLayout并不需要明确地声明包含多少行.多少列,而是通过TableRow,以及其他组件来控制表格的行数和列数, ...

  3. [android] 表格布局和绝对布局

    /*****************2016年4月28日 更新*************************************/ 知乎:为什么Android没有像iOS一样提供autolay ...

  4. Android 表格布局 TableLayout

    属性介绍 stretchColumns:列被拉伸 shrinkColumns:列被收缩 collapseColumns:列被隐藏 举例测试 <TableLayout android:id=&qu ...

  5. android横屏布局文件设置

    一.AndroidManifest.xml配置 1.在AndroidManifest.xml的activity(需要禁止转向的activity)配置中加入   android:screenOrient ...

  6. android动态设置边框颜色

    <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http: ...

  7. Android:控件布局(表格布局)TableLayout

    TableLayout继承LinearLayout 实例:用表格布局实现计算机布局>>>>>>>>>>>> 有多少个TableR ...

  8. Android基础_2 Activity线性布局和表格布局

    在activity的布局中,线性布局和表格布局是最简单的,这次分别从线性布局,表格布局以及线性布局和表格混合布局做了实验,实验中只需要编写 相应的xml的代码,java代码不需要更改,因为我们这里只是 ...

  9. .Net程序猿玩转Android开发---(8)表格布局TableLayout

    表格布局TableLayout是Android中比較经常使用的一个布局控件,既然是表格,肯定有行和列,TableLayout中的行有TableRow组成.列依据每行控件的数量来确定 假如第一行有3个控 ...

随机推荐

  1. [修正] Firemonkey Windows 控件有虚线残影问题

    说明:在 Wndows 显示时,有时控件左方会显示一条虚线 适用:Firemonkey Windows (Berlin 或更高版) 修正方法: 请将源码 FMX.Canvas.D2D.pas 复制到自 ...

  2. Retrofit+Rxjava observable转javabean失败

    报错提示: Caused by: java.lang.IllegalArgumentException: Unable to create call adapter for io.reactivex. ...

  3. Android-ListView-(BaseAdapter使用)

    在Android中就提供了专门列表显示条目的控件,ListView控件,ListView控件不是一次性加载全部数据,他是只加载用户在屏幕看得到的数据,当用户滑动的过程中在去加载新的数据,同时会自动销毁 ...

  4. Partition--分区拆分和分区合并

    --=========================================== --准备测试数据 USE [DB0001] GO CREATE PARTITION FUNCTION [pf ...

  5. 数独高阶技巧入门之三——Fish

    术语Fish代表了一组工作原理相同的关于特定候选数的解题技巧(Fish技巧直接产生自数独规则——每个单元内的数字都不能重复),Fish家族成员包括“体型”从小到大的X-Wing.Swordfish. ...

  6. 串口实现FIFO接受数据(V2)

    在上一次的基础上添加了不同需求缓冲区大小可变的更改. /* * 串口的FIFO简单读取实现 * 功能,实现串口的FIFO实现 * 使用方法: * 更新时间:2017.9.26 * 版本:v2.0.0 ...

  7. 牛客网提高组模拟赛第五场 T1同余方程(异或)(位运算)

    区间不好做,但是我们可以转化成前缀来做.转化为前缀之后之后就是二维前缀和. 但是我还是不怎么会做.所以只能去看吉老师的题解 (确定写的那么简单真的是题解???). 我们要求模一个数余0,就等于找它的倍 ...

  8. 如何用Python做Web开发?——Django环境配置

    用Python做Web开发,Django框架是个非常好的起点.如何从零开始,配置好Django开发环境呢?本文带你一步步无痛上手.     概念 最近有个词儿很流行,叫做“全栈”(full stack ...

  9. 带你玩转Visual Studio——带你高效开发

    VassistX的简单介绍与下载安装 简单介绍 VassistX的全称是Visual Assist X,是whole tomato开发的一个非常好用的插件,可用于VC6.0及Visual Studio ...

  10. linux命令之磁盘与文件系统管理命令(上)

    1.fdisk:磁盘分区工具 该命令是linux下常用的磁盘分区工具,但是只能给小于2TB的磁盘划分分区. 常用参数为-l,显示所有磁盘分区的信息. 示例: 1)显示磁盘分区列表 [root@boxi ...