user2996988
user2996988

Reputation: 17

Color text to EditText

I'm having difficulty in putting the text color of a EditText chosen from ColorPicker. how should I do?

private void cColor(int color) {
    int rgb = Color.red(color) + Color.blue(color) + Color.green(color);
    mCat.setTextColor();

}

Upvotes: 0

Views: 175

Answers (2)

ramaral
ramaral

Reputation: 6179

Not sure I understand your question, but if you want to get the color based on RGB parts try this:

private void cColor(int red, int green, int blue) {

    int rgb = Color.rgb(red, green, blue)

    mCat.setTextColor(rgb);
}

Upvotes: 0

Rahul Gupta
Rahul Gupta

Reputation: 5295

Just do :-

editText.setTextColor(Color.RED + Color.BLUE);

or if you have colour codes defined in strings.xml or colors.xml, Do this :-

    editText.setTextColor(getResources().getColor(R.color.red)+ getResources().getColor(R.color.blue));

strings.xml

    <color name="red">#FF0000</color>
    <color name="blue">#0000FF</color>

Upvotes: 1

Related Questions