BasILyoS
BasILyoS

Reputation: 1005

How to set a Color from resources?

when changing TextView color programmatically from my own color.xml it doesn't give me the real color but if I use the android colors it will work fine

for example

android color: textview.setTextColor(Color.BLACK);
android color: textview.setTextColor(Color.WHITE);
android color: textview.setTextColor(Color.BLUE);

Android Colors will give the same colors

my own color: textview.setTextColor(color.maroon); color code(#800000)
my own color: textview.setTextColor(color.MistyRose); color code(#FFE4E1)
my own color: textview.setTextColor(color.OldLace); color code(#FDF5E6)

my own colors will give another colors

any help??

Upvotes: 0

Views: 246

Answers (1)

Jagadesh Seeram
Jagadesh Seeram

Reputation: 2664

Try this...

textView.setTextColor(getResources().getColor(R.color.some_color));

Upvotes: 3

Related Questions