How to set bold title in Action Bar?
13,292
Solution 1
Can you please try with this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyTheme.MyActionBar</item>
</style>
<style name="MyTheme.MyActionBar"parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">@style/MyTheme.MyActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.MyActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:background">#81CFEB</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
Solution 2
For those using AppCompat, you'll need something like this:
<style name="MyTheme" parent="Theme.AppCompat">
<item name="android:actionBarStyle">@style/MyTheme.ActionBar</item>
<item name="actionBarStyle">@style/MyTheme.ActionBar</item>
</style>
<style name="MyTheme.ActionBar" parent="Widget.AppCompat.ActionBar.Solid">
<item name="titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="TextAppearance.AppCompat">
<item name="android:background">#81CFEB</item>
<item name="android:textStyle">bold</item>
</style>
Related videos on Youtube
Author by
MarcForn
Updated on June 07, 2022Comments
-
MarcForn almost 2 years
I am editing the style xml trying to get the Activity title bold.
<style name="MyTheme" parent="@android:style/Theme.Holo.Light"> <item name="android:actionBarStyle">@style/MyActionBar</item> </style> <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar"> <item name="android:background">#81CFEB</item> <item name="android:textStyle">bold</item> </style>
But only what I can set is the background color desired. I do not why the textStyle is not set to bold.
Anyone know how to solve it?
-
kibitzerCZ about 8 yearsSeems the first item in MyTheme.ActionBar is not needed.
-
Sam about 8 yearsI think it might be for back compat @kbitzerCZ?
-
kibitzerCZ about 8 yearsI have tried to leave it out for both 6.0.1 (API 23) and 4.0.3 (API 15) and it works (hope I'm not missing something).
-
Sam about 8 yearshmm ok, with things like
primaryColor
you sometimes need to double up like that. i've removed it based on your tests though -
Toby Speight about 7 yearsWhilst this code snippet is welcome, and may provide some help, it would be greatly improved if it included an explanation of how it addresses the question. Without that, your answer has much less educational value - remember that you are answering the question for readers in the future, not just the person asking now! Please edit your answer to add explanation, and give an indication of what limitations and assumptions apply.