实用代码3
来源:互联网 发布:flash制作软件 编辑:程序博客网 时间:2024/05/29 19:52
1、文字的颜色随状态而更改:放在res/color/目录下,使用android:textColor
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:color="#3334ca"/> <item android:state_focused="true" android:color="#3334ca"/> <item android:state_pressed="true" android:color="#3334ca"/> <item android:color="#766545"/></selector>
2、背景颜色随状态改变:放在res/color/目录下,使用android:background:
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true"><shape> <gradient android:angle="0" android:centerColor="#12dcf4" android:endColor="#12dcf4" android:startColor="#12dcf4" /> </shape></item> <item android:state_focused="true"><shape> <gradient android:angle="0" android:centerColor="#12dcf4" android:endColor="#12dcf4" android:startColor="#12dcf4" /> </shape></item> <item android:state_pressed="true"><shape> <gradient android:angle="0" android:centerColor="#12dcf4" android:endColor="#12dcf4" android:startColor="#12dcf4" /> </shape></item> <item><shape> <gradient android:angle="0" android:centerColor="#02cd12" android:endColor="#02cd12" android:startColor="#02cd12" /> </shape></item></selector>
3、获取字宽:
/** * 计算字宽(若设置了textStyle需进一步设置TextPaint) * * @param text * 文字 * @param size * 文字大小 * @return 此段文本的宽度 */public static float getTextWidth(String text, float size) {TextPaint tp = new TextPaint();tp.setTextSize(size);return tp.measureText(text);}
0 0
- 实用代码3
- Javascript实用代码(3)
- 实用代码块记录3
- 实用代码
- 实用代码
- 实用代码
- 实用代码
- 实用代码
- 【实用代码】
- 实用代码
- vim实用系列3:vim格式化代码
- 3款实用在线JS代码工具
- ASP实用代码
- ASP实用代码 (转载)
- 珍藏的实用代码
- javascript实用代码大全
- javascript实用代码大全
- javascript实用代码大全
- [资源下载] T-Kernel 相关的 spec
- Mac OS X 通过brew安装命令行工具
- Android控制界面布局的两种方式
- poj2002 STL pair解法
- Arduino学习笔记2--安装Arduino系统
- 实用代码3
- 本机数据库减肥
- 【图像算法】高斯模糊+径向缩放模糊
- 5个强大的Java分布式缓存框架推荐
- 桌面Linux缺应用程序,企业办公是切入口
- Node.js简介——入门级别
- ORACLE 创建用户,权限等
- Qwt(ColorMap,Clipper,Compass,DialNeedle)参考---from Qwt6.1.1
- 最大熵模型