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.
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.
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.
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);
}
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.
You can create a new TextView and get the color from it.
TextView dummy = new TextView(getActivity());
myTextView.setTextColor(dummy.getTextColors());
android:textColor=
Should do the trick, can also be invoked dynamic:
setTextColor(int)
http://developer.android.com/reference/android/widget/TextView.html for more on TextView
© 2022 - 2024 — McMap. All rights reserved.