Android EditText 改变边框颜色
第一步:为了更好的比较,准备两个一模一样的EditText(当Activity启动时,焦点会在第一个EditText上,如果你不希望这样只需要写一个高度和宽带为0的EditText即可避免,这里就不这么做了),代码如下:
<EditText
android:layout_width="fill_parent"
android:layout_height="36dip"
android:background="@drawable/bg_edittext"
android:padding="5dip"
android:layout_margin="36dip"
android:textColorHint="#AAAAAA"
android:textSize="15dip"
android:singleLine="true"
android:hint="请输入..."
/>
接下来建立三个xml文件,分别为输入框未获得焦点时的背景,输入框获得焦点时的背景,selector背景选择器(这里能获得输入框什么时候获得和失去焦点),代码如下:
bg_edittext_normal.xml(未获得焦点时)
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<corners android:radius="3dip"/>
<stroke
android:width="1dip"
android:color="#BDC7D8" />
</shape>
bg_edittext_focused.xml(获得焦点时)
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<corners android:radius="3dip"/>
<stroke
android:width="1dip"
android:color="#728ea3" />
</shape>
bg_edittext.xml(selector选择器,这方面资料网上很多)
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:drawable="@drawable/contact_edit_edittext_normal" />
<item android:state_focused="true" android:drawable="@drawable/contact_edit_edittext_focused" />
</selector>
这样就OK了,效果图如下:

第二个输入框边框变为深色,是不是这样更友好点。
Android EditText 改变边框颜色的更多相关文章
- 【Android】Android EditText 去除边框
[Android]Android EditText 去除边框 将EditText属性设置修改 android:background="@null" //////////////// ...
- EditText之边框颜色
EditText的自带属性里没有设置边框颜色的 有俩种方式可以达到效果 一种是网上比较推崇的用图作背景,另一种则是自绘 图作背景的: 首先重新定义一个style.在values文件夹下新建一个styl ...
- android动态设置边框颜色
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http: ...
- android edittext 去边框 去下划线
EditText的background属性设置为@null就搞定了:android:background="@null"style属性倒是可加可不加 附原文:@SlumberMac ...
- android edittext 去边框
EditText的background属性设置为@null就搞定了:android:background="@null" style属性倒是可加可不加 附原文:@SlumberMa ...
- DBGridEh使用指南改变边框颜色
DBGridEh使用指南 鹅倌0人评论422人阅读2012-08-06 15:17:59 1.设置表头,是否允许多表头,设置是否只读. dbgrdh1.TitleFont.Color:=clBlu ...
- VS中基于对话框的MFC利用换肤改变边框颜色及格式
第一版本: http://ishare.iask.sina.com.cn/f/13836420.html?from=like 2. http://www.cnblogs.com/phinecos/ar ...
- Delphi给窗体镶边-为控件加边框,描边,改变边框颜色
PS:因为我现在用的电脑是WIN7 64位系统,所以没有实现功能,不知道XP是否可行. //1.定义方法 procedure WMNCPaint(var Msg : TWMNCPaint); mess ...
- Android开发---如何操作资源目录中的资源文件3--圆角边框、背景颜色渐变效果、边框颜色
Android开发---如何操作资源目录中的资源文件3 效果图 1.圆角边框 2.背景颜色渐变效果 1.activity_main.xml 描述: 定义了一个shape资源管理按钮 <?xml ...
随机推荐
- CvMat and cv::Mat
CvMat: typedef struct CvMat { int type; int step; /* for internal use only */ int* refcount; int hdr ...
- Video Codecs by FOURCC 视频格式编码
FOURCC Name Summary 1978 A.M.Paredes predictor This is a LossLess video codec. >>> 2VUY 2VU ...
- [转] - 如何用QTcpSocket传送图片
我们知道,tcp网络编程发送数据是利用套接字来实现,将要传输的东西转化为数据流再进行传输,为了确保数据传输的准确性和安全性,我们在发送数据流前发送一个quint32的常量来表示所要发送的数据的大小:当 ...
- Task Scheduler Error and Success Constants (Windows)
If an error occurs, the Task Scheduler APIs can return one of the following error codes as an HRESUL ...
- DirectX基础学习系列4 颜色和光照
4.1颜色表示 RGB颜色:D3DCOLOR 可以用宏D3DCOLOR_ARGB(a,r,g,b) D3DCOLOR_XRGB(255,r,g,b) 另外一种浮点表示:D3DCOLORVALUE, ...
- 使用ngrok
使用ngrok让微信公众平台通过80端口访问本机 首先声明我是用java-tomcat来研究微信公众平台的. 微信公众平台要成为开发者,需要填写接口配置信息中的“URL”和“Token”这两项(参见: ...
- the OS maintains a number of queues
COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION To do its job, the OS ...
- 控制变量法-初中物理-Nobel Lecture, December 12, 1929-php执行SET GLOBAL connect_timeout=2效果
$link = mysqli_connect("localhost", "wu", "wp", "wdb"); $sql ...
- Aliasing 走样
Computer Science An Overview _J. Glenn Brookshear _11th Edition Have you ever noticed the weird &quo ...
- Windows注册表(持续更新)
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom 下, 设置DWORD 值 ZoomDisabled 等于 1.