What is default color for text in textview?

2019-01-31 16:03发布

I set the color to red , and after that I want to set the color again back to default, but I do not know what is default color, does anyone knows ?

8条回答
对你真心纯属浪费
2楼-- · 2019-01-31 16:25

I believe the default color integer value is 16711935 (0x00FF00FF).

查看更多
Evening l夕情丶
3楼-- · 2019-01-31 16:26

There is no default color. It means that every device can have own.

查看更多
4楼-- · 2019-01-31 16:32

I know it is old but according to my own theme editor with default light theme, default

textPrimaryColor = #000000

and

textColorPrimaryDark = #757575
查看更多
贪生不怕死
5楼-- · 2019-01-31 16:35

Actually the color TextView is:

android:textColor="@android:color/tab_indicator_text"

or

#808080
查看更多
放我归山
6楼-- · 2019-01-31 16:41

You can save old color and then use it to restore the original value. Here is an example:

ColorStateList oldColors =  textView.getTextColors(); //save original colors
textView.setTextColor(Color.RED);
....
textView.setTextColor(oldColors);//restore original colors

But in general default TextView text color is determined from current Theme applied to your Activity.

查看更多
萌系小妹纸
7楼-- · 2019-01-31 16:43

Get these values from attributes:

int[] attrs = new int[] { android.R.attr.textColorSecondary };
TypedArray a = getTheme().obtainStyledAttributes(R.style.AppTheme, attrs);
DEFAULT_TEXT_COLOR = a.getColor(0, Color.RED);
a.recycle();
查看更多
登录 后发表回答