简体   繁体   中英

How to set Title Text Color on Android Custom Action Bar for version less than 3.0

Here are the specs for my android platform from my Build.gradle script for my application

classpath 'com.android.tools.build:gradle:2.3.3'
compileSdkVersion 26
buildToolsVersion "26.0.1"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"

Below is the style i included in my STYLES.XML file:

<style name="customStyle" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="actionBarStyle">@style/customActionBarStyle</item>
    </style>

    <style name="customActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="background">@drawable/custom</item>
        <item name="titleTextColor">#01579B</item>
    </style>

Please can any one briefly help with how to set the title text color on the action bar. Thank you.

<item name="titleTextColor">#01579B</item>

add this item your ActionBar style templet

<item name="android:textColor">@color/red</item>

or

int actionBarTitleId = Resources.getSystem().getIdentifier("action_bar", "id", "android");
if (actionBarTitleId > 0) {
    TextView title = (TextView) findViewById(actionBarTitleId);
    if (title != null) {
        title.setTextColor(Color.RED);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM