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)
myTextView.setTextColor(Color.rgb(154,160,166))
Option 2 (using colour parser)
myTextView.setTextColor(Color.parseColor("#2B3A11"))
Option 3 (using colour resource from colors.xml
)
myTextView.setTextColor(ContextCompat.getColor(context, R.color.<name_of_colour>))
Please login or Register to submit your answer