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. Hexo 最常用的几个命令

    Hexo 约有二十个命令,但普通用户经常使用的大概只有下列几个: hexo s hexo s 启动本地服务器,用于预览主题.默认地址: http://localhost:4000/ hexo s 是  ...

  2. Git SSH Key

     一.设置Git的user name和email: $ git config --global user.name "hhl_vip" $ git config --global ...

  3. [LeetCode 题解]: LetterCombinations

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  4. Iframe 高度自适应 example (跨子域实现)

    跨子域的iframe高度自适应 比如 'https://www.kzwr.com/topics/baidu' 嵌入了 'http://pan.kzwr.com/',这种跨子域的页面,实现起来也比较简单 ...

  5. django+echarts

    思路: 统一返回数据类型为json,然后前端发起Ajax请求后台数据接口 views.py def count_blog(request): # 下面等价于:select distinct auth, ...

  6. Ocelot

    Ocelot——初识基于.Net Core的API网关 Ocelot API网关的实现剖析 微服务网关Ocelot API网关Ocelot 使用Polly 处理部分失败问题 谈谈微服务中的 API 网 ...

  7. 【maven】---聚合和继承

    前言 自从我知道写maven实战这本书的作者长得随心所欲后,我再拿起这本书真心的不想看前言了.下面分享一下maven中的所谓的聚合和继承. 内容 下文中的子本指的是:多个maven项目. 父本指的是: ...

  8. Docker容器基础认知

    ## 一. [docker](http://www.itxdm.me/archives/tag/docker/)概念 [Docker](http://www.itxdm.me/wp-content/p ...

  9. centos6,7中防火墙基本用法

    centos 7中 1.永久开放端口8080 firewall-cmd --zone=public --add-port=8080/tcp --permanent (添加端口后,重启防火墙后才能查看) ...

  10. dataTable 从服务器获取数据源的两种表现形式

    var table = $('#example1').DataTable({ "processing": true,//加载效果 "autoWidth": fa ...