1
I have a button created in my class Main
via code, that is, programmatically. See:
Button btnJonSnow = new Button(this);
btnJonSnow.setText("Jon Snow");
How can I program the color of the button text?
1
I have a button created in my class Main
via code, that is, programmatically. See:
Button btnJonSnow = new Button(this);
btnJonSnow.setText("Jon Snow");
How can I program the color of the button text?
2
To set a color for the button text you need to use the attribute setTextColor()
. Then to redeem the color you can use the static method getColor()
of the public class Contextcompat. Take an example:
Button btnJonSnow = new Button(this);
btnJonSnow.setText("Jon Snow");
btnJonSnow.setTextColor(ContextCompat.getColor(mContext, R.color.colorAccent));
Browser other questions tagged java android
You are not signed in. Login or sign up in order to post.