自定义android EditText样式及使用方式
来源:互联网 发布:品牌网络推广渠道 编辑:程序博客网 时间:2024/05/22 07:00
开发中需要对EditText样式进行特殊化定义,使用selector进行获取焦点和失去焦点的样式设计:
代码实现:
searchText.setBackgroundResource(R.drawable.search_edit_selector);
所有的样式和selector都放在drawable目录;
edit_selector.xml书写方式:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/search_edittext_style" android:state_window_focused="false"/>
<item android:drawable="@drawable/search_edittext_style_focused" android:state_focused="true"/>
</selector>
search_edittext_style.xml样式书写,使用layer-list 实现:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<!-- //框为矩形 -->
<shape android:shape="rectangle" >
<!-- //用白色来填充里面 -->
<solid android:color="#BBDCE0" />
<!-- //边框是1dp的线 -->
<stroke
android:width="1dp"
android:color="#FFFFFF" />
</shape>
</item>
</layer-list>
search_edittext_style_focused.xml样式书写:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<!-- //框为矩形 -->
<shape android:shape="rectangle" >
<!-- //用白色来填充里面 -->
<solid android:color="#FFFFFF" />
<!-- //边框是1dp的线 -->
<stroke
android:width="1dp"
android:color="#FFFFFF" />
</shape>
</item>
</layer-list>
- 自定义android EditText样式及使用方式
- android EditText自定义样式
- Android EditText样式自定义
- android EditText自定义样式
- android EditText自定义样式
- Android自定义EditText样式
- android EditText自定义样式
- android EditText自定义样式
- 自定义EditText样式及光标
- Android Studio 自定义EditText样式.
- 自定义android EditText输入框光标样式
- Android EditText简单自定义边框样式
- 如何自定义EditText样式
- 自定义EditText样式
- 自定义EditText hint 样式
- EditText自定义样式
- zxing-android-embedded的使用及自定义样式仿微信的
- 自定义样式dialog及使用
- html中a标签点击去掉高亮背景
- Linux下的tty和pts详解
- 【linux系统加固之】uclibc加固
- 简单的生成二维码的小demo,扫描后可以看到你自定义的信息
- RecycleView子view不能全屏
- 自定义android EditText样式及使用方式
- 狗眼看芯片之ARM
- 解决 - java.lang.OutOfMemoryError: unable to create new native thread
- ReSharper Ultimate 10.0.0.2
- mybatis时间段查询(sql)
- /dev/sdc1 is apparently in use by the system; will not make a filesystem here!
- Gulp 简单使用说明
- sql语句讲解
- voip相关书籍