android 用 XML 绘制底部边框
由于项目的一个页面要展现很多的信息,EditView的边框都展现出来的话,就显得页面非常的拥挤凌乱。所以就希望只显示边框底部,其余的三条边都不要显示。
在网上查了很多的资料,想要用shape的line来画线。然,对line的介绍都很少,基本都是一笔带过。但是用line画线时,总是在中间进行绘制,根本就不能在底部绘制。尝试了很多的办法,也不能把线挪到底部出现。只好放弃。不过shape的line在中间出现的功能,倒是可以用来进行类似于 划掉原价 或者是 表示去掉某一文字 的功能画线。
采用如下方法shape+rectangle,可以达到底部绘制边框的效果,把solid的颜色更换成自己项目的背景色即可:
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetTop="-2dp"
android:insetRight="-2dp"
android:insetLeft="-2dp">
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="#FF0000" />
<solid android:color="#000000" />
</shape>
</inset>
其余的相关技巧,可以参看http://blog.csdn.net/kufeiyun/article/details/45563545,这里介绍的非常详细。