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>

界面效果图

更多相关文章

  1. Android优化之布局优化
  2. Android(安卓)Fragment用法详解(2)--动态添加Fragment
  3. Android应用屏幕适应问题的解决
  4. android列表【android开发记录片】android下实现圆角列表布局控
  5. [Android(安卓)实例] 史上最全的Android的Tab与TabHost讲解
  6. 新浪微博布局学习――妙用TabHost
  7. android shape的使用详解
  8. ListView(二)
  9. Android(安卓)App自适应draw9patch不失真背景.9.png详解

随机推荐

  1. 个人知识体系(持续更新)
  2. android设备获取当前wifi下的路由器的mac
  3. Android发送xml数据给服务器的方法
  4. Android函数计算器(含源码,Android测试工程
  5. Java中为何与0xff进行与运算
  6. android下m、mm、mmm编译命令的使用
  7. Android(安卓)学生信息管理系统
  8. 使用Visual Studio 2015开发Android(安卓
  9. android的EditText获取另一个焦点
  10. 横屏启动activity,点击屏幕的单击、双击