view 设置背景颜色的集中方式
2016-09-13 14:14
162 查看
1.引用color 包下的资源
convertView.setBackgroundColor(getResources().getColor(R.color.colorMaterial));
注:通过获得资源文件进行设置。根据不同的情况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>
2.使用系统自带的颜色类
tText.setTextColor(android.graphics.Color.RED);//系统自带的颜色类
3.设置16进制的数值
tText.setTextColor(0xffff00ff);
注:0xffff00ff是int类型的数据,分组一下0x|ff|ff00ff,0x是代表颜色整数的标记,ff是表示透明度,ff00ff表示颜色,注意:这里ffff00ff必须是8个的颜色表示,不接受ff00ff这种6个的颜色表示。
4.利用Color类
tText.setTextColor(android.graphics.Color.parseColor("#87CEFA")) ;
1.引用color 包下的资源
convertView.setBackgroundColor(getResources().getColor(R.color.colorMaterial));
注:通过获得资源文件进行设置。根据不同的情况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>
2.使用系统自带的颜色类
tText.setTextColor(android.graphics.Color.RED);//系统自带的颜色类
3.设置16进制的数值
tText.setTextColor(0xffff00ff);
注:0xffff00ff是int类型的数据,分组一下0x|ff|ff00ff,0x是代表颜色整数的标记,ff是表示透明度,ff00ff表示颜色,注意:这里ffff00ff必须是8个的颜色表示,不接受ff00ff这种6个的颜色表示。
4.利用Color类
tText.setTextColor(android.graphics.Color.parseColor("#87CEFA")) ;
相关文章推荐
- ios给view设置背景颜色的正确方式
- 设置View的背景颜色
- 设置不同事件View背景颜色
- 给一个android的TextView设置背景颜色动态显示,到那时好像不起作用。我是少了什么东西么?
- android--设置TextView部分文字的颜色和背景(高亮显示)
- iOS 7 UITableview 在Plain模式下 设置背景颜色无效
- 如何将TextView设置背景透明(不改变本身颜色)
- 设置UITableView Section的背景颜色和字体颜色
- 当前ViewGroup背景设置系统背景并增加颜色滤镜效果
- 设置UITableView Section的背景颜色和字体颜色 ----------自
- android--设置TextView部分文字的颜色和背景(高亮显示)
- android--设置TextView部分文字的颜色和背景(高亮显示)
- IOS-UITableView设置背景图片,方式与众不同。
- android--设置TextView部分文字的颜色和背景(高亮显示)
- UITableView背景颜色设置
- 最新历史版本 :android--设置TextView部分文字的颜色和背景(高亮显示)
- 最新历史版本 :android--设置TextView部分文字的颜色和背景(高亮显示)
- IOS_设置UITableView Section的背景颜色和字体颜色(自定义section布局)
- uitableview group的一些问题 (设置两个section之间的距离,设置背景颜色 等)在plain下去掉foot view的粘性
- View背景颜色设置&Fragment&FragmentDialog