I've been trying to find solution but none worked for me. Activity theme:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/white</item>
<item name="actionBarTheme">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:background">@color/colorPrimaryDesignV4</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
<item name="colorControlNormal">@color/white</item>
<item name="android:titleTextStyle">@style/TitleText</item>
</style>
<style name="TitleText" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#DE0F17</item>
<item name="android:textSize">20sp</item>
</style>
all the attributes in MyActionBar work fine but last one. Title color and sizes are unaffected no matter what.
how can i change it?
I am using this and it works for me
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="titleTextColor">@android:color/white</item>
<item name="subtitleTextColor">@android:color/white</item>
</style>
titleTextColor
is an attribute available for v23 only.
Check that in your layout xml file you don't have an android:theme
attribute specified for your <Toolbar>
, which would have priority over the main theme
Override your actionBarStyle
attribute as pointed out everywhere over the internets.
<style name="Theme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="actionBarStyle">@style/ActionBarStyle</item> </style> <style name="ActionBarStyle" parent="Theme.AppCompat.Light.DarkActionBar" > <item name="android:titleTextStyle">@style/ActionBarTitle</item> </style> <style name="ActionBarTitle" parent="Widget.AppCompat.ActionBar"> <item name="android:textColor">@android:color/black</item> </style>
This line of code works for me
app:titleTextColor="@android:color/white"
it's working for me hope it will help u
Method1:
Toolbar toolbar= (Toolbar)activity.findViewById(R.id.action_bar);
if (toolbar!= null){
toolbar.setTitleTextColor(Color.RED);
}
Method2:
Toolbar toolbar= (Toolbar)activity.findViewById(R.id.action_bar);
if (toolbar!= null){
toolbar.setTitleTextColor(Color.parseColor("#3A1452"));
}
Method3:
Toolbar toolbar= (Toolbar)activity.findViewById(R.id.action_bar);
if (toolbar!= null){
toolbar.setTitleTextColor(getResources().getColor(R.color.color_carrot));
}
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.