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. 洛谷P2173 [ZJOI2012]网络(10棵lct与瞎jb暴力)

    有一个无向图G,每个点有个权值,每条边有一个颜色.这个无向图满足以下两个条件: 对于任意节点连出去的边中,相同颜色的边不超过两条. 图中不存在同色的环,同色的环指相同颜色的边构成的环. 在这个图上,你 ...

  2. linux命令の ./configure --prefix

    源码的安装一般由3个步骤组成:配置(configure).编译(make).安装(make install). Configure是一个可执行脚本,它有很多选项,在待安装的源码路径下使用命令./con ...

  3. python中用ElementTree.iterparse()读取xml文件中的多层节点

    我在使用Python解析比较大型的xml文件时,为了提高效率,决定使用iterparse()方法,但是发现根据网上的例子:每次if event == 'end':之后elem.clear()或者是每次 ...

  4. [Postgres]关于Postgres的INHERIT,分表

    实在是很强大的功能 可以通过Check的制约把结构相同的表合并起来,或者反过来说,可以在一个表名下数据库自动的根据Check条件往对应的分表里存储数据 [USER_DATA表] CREATE TABL ...

  5. 判断客户端是iOS还是Android,判断是不是在微信浏览器打开

    bool flag = false; string agent = System.Web.HttpContext.Current.Request.UserAgent.ToLower(); string ...

  6. c# ref与out的区别

     c#  ref与out的区别 相同点:都是输出参数 不同点: ref: 1.必须初始化,即:必须赋初始值: 2.有进有出: 3.用在需要被调用的方法修改调用者的引用的时候. 4.是传递参数的地址 o ...

  7. Template 动画

    如果设置Template的动画,也就意味着对每一个具有此Template的对象进行动画处理. 比如对ListBoxI的ItemTemplate进行设置,添加动画,触发器等,每一个ListBoxItem ...

  8. Tomcat企业级应用

    简介 Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache.Sun 和其他一些公司及个人共同开发而成.由 ...

  9. scrapy连接MySQL

    Scrapy中连接MySQL所需要做的工作如下: 1.settings中需要设置的部分 # 启动管道组件 ITEM_PIPELINES = { 'QianChengWuYu.mongoDBPiplel ...

  10. for ++i i++

    study from: https://zhidao.baidu.com/question/339305815.html 处理方式的不同,速度上的微妙不同 有些高手能喜欢用++i,速度上快一点