在res/drawable下创建3个xml文件,分别为:
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
<?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/bg_edittext_normal" /> <item android:state_focused="true" android:drawable="@drawable/bg_edittext_focused" /> </selector>
然后在EditText控件中设置属性即可:android:background="@drawable/bg_edittext"
总结:以上内容主要涉及到Android shape以及selector的使用
相关推荐
小白分享 Android自定义EditText
Android自定义EditText,实现带清除功能的输入框
android-EditText边框颜色 ,完整源码,适用初学者
android 自定义edittext 光标,下划线颜色仅此而已kkkk.
android 自定义editText和多级树 editText 自带日历按钮和添加按钮 点击添加按钮选人 选人界面是一个多级树
android 自定义EditText,可删除输入框内容,或者修改文本框显示的类型。
大家在做商城购物类的APP时,肯定遇到过需要自定义带加减的EditText 那么我上传的这个自定义的EditText: 1.可以根据个人的实际UI需求,修改成自己喜欢的颜色和形状。 2.里面的加和减的业务逻辑判断已完善,大部分...
Android 自定义edittext(实现删除,手机号码样式,选中,未选中底部状态改变.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
android自定义EditText删除按钮。
Android自定义EditText实现带清除功能的输入框.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
NULL 博文链接:https://renxin-327666062-qq-com.iteye.com/blog/1666694
主要为大家详细介绍了Android自定义EditText实现登录界面,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
自定义EditText。限制输入文字为两行,添加两行行线。可以根据实际需求修改
自定义一个带icon图标带删除按钮的EditText,简洁代码。
Android改EditText背景及光标Demo(开发工具:Android Studio)
Android 自定义view-仿新浪微博#话题#插入EditText 博客地址http://blog.csdn.net/u014702653/article/details/52799715
栗子——自定义EditText实现右下角计数控件
带清除图标的 EditText ( 自定义EditText
自定义EditText之多个清除按钮,多了一个清除按钮