Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the default text color for android TextView?

I cannot get the default gray text color for TextView (and maybe other views) in Android 23.

I tried to get it with this code :

TextView textview= (TextView) mActivity.findViewById(R.id.my_textview);

int colorFirstTry = title.getCurrentTextColor(); // black
int colorSecondTry = title.getTextColors().getDefaultColor(); // black
int colorthirdTry = ContextCompat.getColor(mActivity, android.R.color.primary_text_light); // black

My theme is the default theme used in an blank activity project (AppTheme from Theme.AppCompat.Light.DarkActionBar parent). Colors are blue, darker blue and purple for respectively colorPrimary, colorPrimaryDark and colorAccent.

When i navigate through all Theme.AppCompat.Light.DarkActionBar parents, i find a similar gray value :

<style name="Base.V7.Theme.AppCompat.Light" parent="Platform.AppCompat.Light">   
    ...
    <item name="colorPrimaryDark">@color/primary_dark_material_light</item>

But this value shoud be overrided by my app theme value.

like image 474
Burrich Avatar asked Jan 09 '16 20:01

Burrich


People also ask

What is the default text color in Android Studio?

By default, the color of the text will be black until it is changed.

What is the default text color in HTML?

There is no default color defined in HTML. The "default color" is configured in the browser or by the operating system you are using.

What attribute changes the color of TextView?

In XML, we can set a text color by the textColor attribute, like android:textColor="#FF0000" .


1 Answers

As said by Alex here, you can get it by:

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

or

#808080

It worked great for me!

like image 133
Alysson Myller Avatar answered Oct 13 '22 01:10

Alysson Myller