Garmaine Staff asked 2 years ago

What's the most efficient way to set the color of a TextView and why? Is there 1 method that is more memory and/or processor efficient? Or is there no difference at all to what happens with my app when it's running? Is it better to refer to a colour resource than declare RGB everytime I set a colour?

Option 1 (using RGB channel)


Option 2 (using colour parser)


Option 3 (using colour resource from colors.xml)

myTextView.setTextColor(ContextCompat.getColor(context, R.color.<name_of_colour>))