给TableLayou绘制边框--简单方法
2014-06-08 19:09
155 查看
最简单的方法是直接在每个TableRow前加上View控件,自动会加上一条线,如下:
<View
android:width="match_parent"
android:background="#af3489"
/>
但是似乎不合乎我们的想象,下面的方法是在res/drawable文件夹下建立xml文件,然后引用,每一个元素都会加上边框!很简单,但是不推荐,尤其是想绘制n*n的传统表格的时候!不过至少这个可以实现n*n的表格,也算说得过去!
步骤:
1.在res/drawable文件夹下建立table_frame_gray.xml文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#ffffff" />
<stroke
android:width="0.01dp"
android:color="#848484" />
</shape>
引用时,,如下
<TableRow>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/table_frame_gray"
android:orientation="vertical" >
另外,当方框重合导致边线变粗时,参考如下这种方法,给指定边框加线,但是不推荐,因为到最后的时候,还是会出现边框不一样粗的情况!
android shape指定那几个边有边框
http://stackoverflow.com/questions/2422120/open-sided-android-stroke
最好的办法,参考上一篇文章,个人意见。
<View
android:width="match_parent"
android:background="#af3489"
/>
但是似乎不合乎我们的想象,下面的方法是在res/drawable文件夹下建立xml文件,然后引用,每一个元素都会加上边框!很简单,但是不推荐,尤其是想绘制n*n的传统表格的时候!不过至少这个可以实现n*n的表格,也算说得过去!
步骤:
1.在res/drawable文件夹下建立table_frame_gray.xml文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#ffffff" />
<stroke
android:width="0.01dp"
android:color="#848484" />
</shape>
引用时,,如下
<TableRow>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/table_frame_gray"
android:orientation="vertical" >
另外,当方框重合导致边线变粗时,参考如下这种方法,给指定边框加线,但是不推荐,因为到最后的时候,还是会出现边框不一样粗的情况!
android shape指定那几个边有边框
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!-- This is the line --> <item android:top="-1dp" android:right="-1dp" android:left="-1dp"> <shape> <solid android:color="@android:color/transparent" /> <stroke android:width="1dp" android:color="#ffffff" /> </shape> </item> </layer-list>
http://stackoverflow.com/questions/2422120/open-sided-android-stroke
最好的办法,参考上一篇文章,个人意见。
相关文章推荐
- Android实现给TableLayou绘制边框的方法
- Android实现给TableLayou绘制边框的方法
- 在IE下去除边框的简单方法
- 用CSS定义单像素表格边框的简单方法
- 简单实现ImageView的加边框颜色的方法
- js+html5实现canvas绘制简单矩形的方法
- 利用GLUT实现在OpenGL中绘制文本的简单方法
- 设边框为1px的最简单方法-2006-6-26-2
- 用CSS3绘制三角形的简单方法
- C#移动无边框窗体的简单方法
- MFC绘制椭圆的两种简单方法
- php使用Jpgraph绘制简单X-Y坐标图的方法
- 利用GLUT实现在OpenGL中绘制文本的简单方法
- Android 设置dialog背景全透明无边框的最简单的方法
- jqPlot——基于jquery的图表绘制工具简单使用,jqPlot 在firefox 火狐浏览器里面,图表右侧的标题,变形的解决方法
- 一种将图片绘制在一个圆形区域内的简单方法——CGContextClip
- 去掉html里面的边框的简单方法
- 转载 Android简单实现ImageView的加边框颜色的方法
- Android之最简单的ImageView加边框方法
- Android之最简单的ImageView加边框方法