Android – How to get the default text color for android TextView

androidcolorstextviewthemesview

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.

Best Answer

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

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

or

#808080

It worked great for me!