Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set bold title in Action Bar?

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?

like image 278
MarcForn Avatar asked Sep 23 '13 22:09

MarcForn


2 Answers

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>
like image 68
Pradip Avatar answered Sep 20 '22 11:09

Pradip


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>
like image 38
Sam Avatar answered Sep 18 '22 11:09

Sam