How to set text color in android app for all text?

Viewed 79128

I want to define a default text color for my android app.

I have a base activity class, that all activities are extended from it and I thought this might be a good place to define the colors.

If not what is a better solution? Maybe styles?

Trouble is this, all is new to me, so feel free to advise me and provide code snippets and explanations as well.

This is what my base class looks like. As you can see it's pretty empty

package com.ccslocal.mobile.quiz.jls;

import android.app.Activity;
import android.os.Bundle;

public class BaseActivity extends Activity {
    //set up app preferences here
}
6 Answers
  • Create style for TextView:

    <style name="TextViewTheme">
        <item name="android:textColor">@android:color/white</item>
    </style>
    
  • Apply it in style for App:

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:textViewStyle">@style/TextViewTheme</item>
    </style>
    
  • And remember to change style in AndroidManifest.xml:

    <application
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        ...
    </application>
    

@android:color/white

yes you can change default color of react native app only add this line in styles.xml file of android src

Related