We can use various functions from the Color class to change text colour programatically
- TextView text = (TextView) findViewById(R.id.text); text.setTextColor(Color.parseColor("#FFFFFF"));
- holder.text.setTextColor(Color.RED);
- Color.parseColor (like LEX uses)text.setTextColor(Color.parseColor("#FFFFFF"));
- Color.rgb and Color.argb holder.text.setTextColor(Color.rgb(200,0,0)); holder.text.setTextColor(Color.argb(0,200,0,0));
- And of course, if you want to define your color in an XML file, you can do this:
<color name="errorColor">#f00</color>
and then use this code to show it:
textView.setTextColor(getResources().getColor(R.color.errorColor));
- You can also insert plain HEX, like so: myTextView.setTextColor(0xAARRGGBB);
No comments:
Post a Comment