android在代码中四种设置控件背景颜色的方法(包含RGB)
2016-04-21 13:26
786 查看
转载请注明出处: http://blog.csdn.net/fth826595345/article/details/9208771
TextView tText=(TextView) findViewById(R.id.textv_name);//第1种:tText.setTextColor(android.graphics.Color.RED);//系统自带的颜色类// 第2种:tText.setTextColor(0xffff00ff);//0xffff00ff是int类型的数据,分组一下0x|ff|ff00ff。0x是代表颜色整数的标记,ff是表示透明度,ff00ff表示颜色,注意:这里ffff00ff必须是8个的颜色表示,不接受ff00ff这样的6个的颜色表示。//第3种:tText.setTextColor(android.graphics.Color.parseColor("#87CEFA")) ; //还是利用Color类;//第4种:tText.setTextColor(this.getResources().getColor(R.color.red));/*通过获得资源文件进行设置。依据不同的情况R.color.red也能够是R.string.red或者R.drawable.red。* 当然前提是须要在对应的配置文件中做对应的配置。如(xml 标签):** <color name="red">#FF0000</color><drawable name="red">#FF0000</drawable><string name="red">#FF0000</string>*/
相关文章推荐
- android调试工具DDMS的使用详解
- android开发框架(六)WindowManager机制
- Android剖析和运行机制
- Android 点击Button显示菜单 (把菜单键放到屏幕上)
- Android 文件存储的简单实现
- Android 使用ProgressBar实现进度条
- android将控件设置为透明色
- Android中使用Fragment实现标题栏(不可滑动)
- Android Studio遇到的问题
- Android ImageView实现圆形头像
- 自动启动支付宝支付宝小插件
- Android中使用printf打印信息
- good blog about android base
- Android开发实践
- [置顶] Android 开发效率
- android 利用mob 进行第三方登录
- AndroidStudio获取(debug/release)签名的sha1值
- Android改变字体大小,适应区域宽度
- 《android开发必知的50个诀窍》笔记Hack-2
- Android 冷启动 热启动 测试