Android: How can I access the default text color? (No theme, just the standard one)

jellyfish picture jellyfish · May 11, 2011 · Viewed 14.8k times · Source

very short question: if I want to set some text (in a TextView) back to the default text color, how can I do this?

I'm not using any themes.

Answer

maGo picture maGo · Oct 22, 2011

I used the solution from jellyfish's comment on the first answer. A lot of code for something so simple as removing color. To make it clear:

private TextView myTextView;
private int defaultTextColor;

public void onCreate(Bundle savedInstanceState) {
    myTextView = (TextView) findViewById(R.id.myTextView);
    defaultTextColor = myTextView.getTextColors().getDefaultColor();
}

public void changeColorBack() {
    myTextView.setTextColor(defaultTextColor);
}