给安卓EditText加边框

来源:互联网 发布:中国gdp历年数据 编辑:程序博客网 时间:2024/05/02 02:23

到了高版本的EditText一般没有边框,只有一条横线,需要自己加,代码如下;

<EditText             android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:hint="请填入账号"            android:selectAllOnFocus="true"            android:background="@drawable/bg_border"            />


其中 bg_border.xml 的代码如下:

<shape xmlns:android="http://schemas.android.com/apk/res/android" ><solid android:color="#ffffff"/> <stroke android:width="1dip" android:color="#00ff00"/></shape>


<solid>标签表示填充色,不能省略否则默认为黑色。<stroke>控制边框颜色和边框粗细。

0 0
原创粉丝点击