Vins
Vins

Reputation: 4119

Color change of a button in code not reflecting

I'm trying to change a color of a button in code as below

 btn_no5.setTextColor(0x8E35EF);

the above change is not reflecting(purple color), the text is disappearing after execution of above piece of code. But if i use the color in xml its reflecting. So how to change this through java ?

Upvotes: 0

Views: 289

Answers (2)

ilango j
ilango j

Reputation: 6037

use like this,

btn_no5.setTextColor(Color.parseColor("#8E35EF"));

Upvotes: 1

Romain Guy
Romain Guy

Reputation: 98521

The color you are using is fully transparent. Use 0xFF8E35EF instead. The first byte is the alpha (transparency) channel.

Upvotes: 7

Related Questions