Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 685
jellyfish Avatar asked May 11 '11 09:05

jellyfish


2 Answers

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);
}
like image 176
maGo Avatar answered Oct 05 '22 07:10

maGo


I used the following way: At the initialization I backuped the default color and when I had to reset I just used the stores value.

like image 37
schlingel Avatar answered Oct 05 '22 09:10

schlingel