Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

possible to change text size/color for ActionBar?

Is there possible way to change size/color of ActionBar's title and subtitle?

I am using ActionBarSherlock for bridging between lower and higher versions. ActionBarSherlock provides way to customize text style in SherlockActionBarCompat, but there seems no way to make it in SherlockActionBarNative.

edit: added by Jake and removed by author

edit: Close to the solution:

<style name="resizeableTitleStyle" parent="TextAppearance.Sherlock.Widget.ActionBar.Title.Inverse">
    <item name="android:textSize">@dimen/action_bar_title_text_size</item>
</style>

<style name="Theme.ResizeableActionBar" parent="Theme.Sherlock.Light.DarkActionBar">
    <item name="actionBarStyle">@style/resizeableActionBarStyle</item>
    <item name="android:actionBarStyle">@style/resizeableActionBarStyle</item>
    <item name="actionBarSize">60dp</item>
    <item name="android:actionBarSize">60dp</item>
</style>

<style name="resizeableActionBarStyle" parent="@style/Widget.Sherlock.Light.ActionBar.Solid.Inverse">
    <item name="titleTextStyle">@style/resizeableTitleStyle</item>
    <item name="android:titleTextStyle">@style/resizeableTitleStyle</item>
</style>

Thank Jake, the author of ABS, for the help.

Now it's almost done, except that the actionBarSize can only be estimated for an approximate absolute dimension(60dp for my app) from quite a few trials; wrap_content causes API2.2 to expand the whole screen and does API4.2.2 exception thrown while parsing xml.

Addition:
when actionBarSize set as 0dp, the output is as (http://i.stack.imgur.com/xX4E1.png , low reputation to post images here directly): API2.2 in the left, the action bar occupies the whole screen without content, API4.2.2 in the right, content does without action bar.

when set as wrap_content, same output for API2.2, and exception thrown as: Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x10

like image 556
user1105115 Avatar asked Jan 13 '23 13:01

user1105115


1 Answers

yes it is possible. You can do it through styles in this way:

<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Medium">
        <item name="android:textColor">@color/green_text_color</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">@dimen/actionbar_textsize</item>
</style>

and use it with:

 <item name="titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
 <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
like image 143
Blackbelt Avatar answered Jan 21 '23 15:01

Blackbelt