给TableLayou绘制边框



给TableLayou绘制边框


效果如下:



思路:使用share作为背景显示边框


步骤:

1.在res/drawable文件夹下建立table_frame_gray.xml文件:

[html]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:shape="rectangle" >  
  4.   
  5.     <solid android:color="#ffffff" />  
  6.   
  7.     <stroke  
  8.         android:width="0.01dp"  
  9.         android:color="#848484" />  
  10.   
  11. </shape>  

2.在布局文件里引用table_frame_gray.xml文件作为背景:

[html]  view plain copy
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:background="#FFFF00"  
  6.     android:paddingBottom="@dimen/activity_vertical_margin"  
  7.     android:paddingLeft="@dimen/activity_horizontal_margin"  
  8.     android:paddingRight="@dimen/activity_horizontal_margin"  
  9.     android:paddingTop="@dimen/activity_vertical_margin"  
  10.     tools:context=".MainActivity" >  
  11.   
  12.     <TableLayout  
  13.         android:layout_width="wrap_content"  
  14.         android:layout_height="wrap_content"  
  15.         android:background="#FF4000"  
  16.         android:stretchColumns="*"  
  17.         android:text="@string/hello_world" >  
  18.   
  19.         <!-- 微博数 -->  
  20.   
  21.         <TableRow>  
  22.   
  23.             <LinearLayout  
  24.                 android:layout_width="wrap_content"  
  25.                 android:layout_height="wrap_content"  
  26.                 android:background="@drawable/table_frame_gray"  
  27.                 android:orientation="vertical" >  
  28.   
  29.                 <TextView  
  30.                     android:layout_width="wrap_content"  
  31.                     android:layout_height="wrap_content"  
  32.                     android:padding="5dp"  
  33.                     android:text="232" />  
  34.   
  35.                 <TextView  
  36.                     android:layout_width="wrap_content"  
  37.                     android:layout_height="wrap_content"  
  38.                     android:padding="5dp"  
  39.                     android:text="微博" />  
  40.             </LinearLayout>  
  41.             <!-- 关注人数 -->  
  42.   
  43.             <LinearLayout  
  44.                 android:layout_width="wrap_content"  
  45.                 android:layout_height="wrap_content"  
  46.                 android:background="@drawable/table_frame_gray"  
  47.                 android:orientation="vertical" >  
  48.   
  49.                 <TextView  
  50.                     android:layout_width="wrap_content"  
  51.                     android:layout_height="wrap_content"  
  52.                     android:padding="5dp"  
  53.                     android:text="38" />  
  54.   
  55.                 <TextView  
  56.                     android:layout_width="wrap_content"  
  57.                     android:layout_height="wrap_content"  
  58.                     android:padding="5dp"  
  59.                     android:text="关注" />  
  60.             </LinearLayout>  
  61.             <!-- 好友数 -->  
  62.   
  63.             <LinearLayout  
  64.                 android:layout_width="wrap_content"  
  65.                 android:layout_height="wrap_content"  
  66.                 android:background="@drawable/table_frame_gray"  
  67.                 android:orientation="vertical" >  
  68.   
  69.                 <TextView  
  70.                     android:layout_width="wrap_content"  
  71.                     android:layout_height="wrap_content"  
  72.                     android:padding="5dp"  
  73.                     android:text="9" />  
  74.   
  75.                 <TextView  
  76.                     android:layout_width="wrap_content"  
  77.                     android:layout_height="wrap_content"  
  78.                     android:padding="5dp"  
  79.                     android:text="粉丝" />  
  80.             </LinearLayout>  
  81.         </TableRow>  
  82.     </TableLayout>  
  83.   
  84. </RelativeLayout>  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值