Search code examples
androidfontsandroid-actionbartitleandroid-layout-weight

ActionBar title weight won't be applied


I'm currently trying to set the font weight of my ActionBar title to bold, with the following code, but it isn't working as expected. What am i doing wrong?

<style name="dActionBar" parent="@android:style/Widget.Holo.ActionBar">
        <item name="android:background">#DDDDDD</item>
        <item name="android:textColor">#FFFFFF</item>
        <item name="android:textStyle">bold</item>
        <item name="android:foreground">#000000</item>
    </style>

The background color and so on is working pretty well.


Solution

  • not all Android fonts have bold style,for example Chinese words must use setFakeBoldText

            final int actionBarTitle = getResources().getIdentifier("action_bar_title", "id", "android");
            final TextView title = (TextView) getActivity().getWindow().findViewById(actionBarTitle);
            title.getPaint().setFakeBoldText(true);