android SearchView 样式修改
try {
Class<?> argClass=mSearchView.getClass();
//指定某个私有属性
Field mSearchHintIconField = argClass.getDeclaredField("mSearchHintIcon");
mSearchHintIconField.setAccessible(true);
View mSearchHintIcon = (View)mSearchHintIconField.get(mSearchView);
mSearchHintIcon.setVisibility(View.GONE);
//注意mSearchPlate的背景是stateListDrawable(不同状态不同的图片) 所以不能用BitmapDrawable
Field ownField = argClass.getDeclaredField("mSearchPlate");
//setAccessible 它是用来设置是否有权限访问反射类中的私有属性的,只有设置为true时才可以访问,默认为false
ownField.setAccessible(true);
View mView = (View) ownField.get(mSearchView);
mView.setBackground(getResources().getDrawable(R.drawable.contacts_search_writebg));
//指定某个私有属性
Field mQueryTextView = argClass.getDeclaredField("mQueryTextView");
mQueryTextView.setAccessible(true);
Class<?> mTextViewClass = mQueryTextView.get(mSearchView).getClass().getSuperclass().getSuperclass().getSuperclass();
//mCursorDrawableRes光标图片Id的属性 这个属性是TextView的属性,所以要用mQueryTextView(SearchAutoComplete)
//的父类(AutoCompleteTextView)的父 类( EditText)的父类(TextView)
Field mCursorDrawableRes = mTextViewClass.getDeclaredField("mCursorDrawableRes");
//setAccessible 它是用来设置是否有权限访问反射类中的私有属性的,只有设置为true时才可以访问,默认为false
mCursorDrawableRes.setAccessible(true);
//注意第一个参数持有这个属性(mQueryTextView)的对象(mSearchView) 光标必须是一张图片不能是颜色,因为光标有两张图片,
//一张是第一次获得焦点的时候的闪烁的图片,一张是后边有内容时候的图片,如果用颜色填充的话,就会失去闪烁的那张图片,
//颜色填充的会缩短文字和光标的距离(某些字母会背光标覆盖一部分)。
mCursorDrawableRes.set(mQueryTextView.get(mSearchView), R.drawable.icon_small_add_delete);
} catch (Exception e) {
e.printStackTrace();
}
参考原文:http://blog.csdn.net/chenshijun0101/article/details/21521137
android SearchView 样式修改的更多相关文章
- 【Android 应用开发】 ActionBar 样式详解 -- 样式 主题 简介 Actionbar 的 icon logo 标题 菜单样式修改
作者 : 万境绝尘 (octopus_truth@163.com) 转载请著名出处 : http://blog.csdn.net/shulianghan/article/details/3926916 ...
- android studio样式文件汇总
android studio样式文件汇总:shape.Theme|styles .selector 1:shape shape用于设定形状,有6个子标签,各属性如下: res/drawable/sty ...
- 这些Android系统样式中的颜色属性你知道吗?
Android 系统样式中的颜色属性 推荐阅读看完后彻底搞清楚Android中的 Attr . Style .Theme 几个常用的颜色属性 先放上一张经典的图片,图片来自网络. 这张图在网上很是流传 ...
- input placeholder属性 样式修改(颜色,大小,位置)
placeholder属性 样式修改 <!DOCTYPE html> <html> <head> <meta charset="utf-8" ...
- Android Studio -修改LogCat的颜色
Android Studio -修改LogCat的颜色 author:Kang,Leo weibo:http://weibo.com/kangyi 效果图 设置 Preference->Edit ...
- ExtJS控件样式修改及美化
Extjs项目对富客户端开发提供了强有力的支持,甚至改变了前端的开发方式,使得开发变得更加趋向于“面向组件”.对界面的美化而言,也是根本性的改变.普通的网页美工面对extjs项目根本无法下手,需要脚本 ...
- Android handler Thread 修改UI Demo
/********************************************************************** * Android handler Thread 修改U ...
- 【转】eclipse android 设置及修改生成apk的签名文件 -- custom debug keystore
原文网址:http://hold-on.iteye.com/blog/2064642 android eclipse 设置及修改生成apk的签名文件 1. 问题: 平时在使用eclipse进行andr ...
- android自定义样式大全:shape,selector,layer-list,style,动画全部内容
原文:http://keeganlee.me/post/android/20150830 以下摘取了部分内容: shape 一般用shape定义的xml文件存放在drawable目录下,若项目没有该目 ...
随机推荐
- Contact
UF3000: 1.wafer进去prober后,默认probercard不会跟chuck上的wafer接触. 2.通过prober界面上的按钮向上移动,使得prober card和wafer的距离为 ...
- JS——鼠标在盒子中的坐标
核心思想: 1.复杂版本:鼠标pageX.pageY的值减去盒子距离顶端的offsetLeft.offsetTop值就是鼠标在盒子中的坐标 2.简单版本:offsetX.offsetY就可获取鼠标相对 ...
- cmd 启动mysql环境变量配置
win10系统:(其他系统类似,改环境变量就可以) 1.我的电脑,右键选择属性,进入系统页面 2.点击高级系统设置,进入系统属性页面 3.点击高级选项卡,点击环境变量,进入环境变量设置 4.选择系统变 ...
- Oracle Sequence不设置cache参数的几个潜在问题(转载)
转载于 http://www.uml.org.cn/sjjm/201204065.asp 在Oracle中,我们没有MYSQL和SQL Server ...
- python_文件io
# -*- coding:UTF-8 -*-#从键盘读入raw_input([prompt]) #函数从标准输入读取一个行,并返回一个字符串(去掉结尾的换行符)#input([prompt]) 函数和 ...
- HDU_1027_Ignatius and the Princess II_全排列
Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ( ...
- hint: not have locally. This is usually caused by another repository pushing
git 提交代码前先pull代码,否则会报如下错误 wangju@wangju-HP-348-G4:~/test/reponselogiccheck$ git statusOn branch mast ...
- spring boot 2.0 报错:“jdbcUrl is required with driverClassName.” 解决办法!
springboot 升级到2.0之后发现配置多数据源的时候报错: "jdbcUrl is required with driverClassName."或者Cause: java ...
- 前端自动化构建工具gulp使用
1. 全局安装 gulp: $ npm install --global gulp 2. 作为项目的开发依赖(devDependencies)安装: $ npm install --save-dev ...
- Python编码格式导致的csv读取错误
Python编码格式导致的csv读取错误(pandas.read_csv) 本文记录python小白我今天遇到的这两个问题(csv.reader和pandas.csv_read): pandas模块“ ...