可以改变文字大小/颜色动作条? [英] possible to change text size/color for ActionBar?

查看:180
本文介绍了可以改变文字大小/颜色动作条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有改变ActionBar的标题和字幕大小/颜色可能的方式?

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

我使用ActionBarSherlock更低和更高版本之间的桥接。 ActionBarSherlock提供了可以自定义的SherlockActionBarCompat文字样式,但似乎没有办法,使其在SherlockActionBarNative。

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>

感谢杰克,ABS的作者的帮助。

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

现在除了actionBarSize只能估计从相当多的试验近似绝对尺寸(60dp我的应用程序),它几乎做到了; WRAP_CONTENT导致API2.2扩大整个屏幕,确实API4.2.2异常解析XML抛出。

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.

添加
当actionBarSize设为0dp,输出作为( http://i.stack.imgur.com/ xX4E1.png ,低信誉后的图像直接在这里):API2.2在左侧,操作栏占据整个屏幕没有内容,API4.2.2在右边,内容确实没有行动吧。

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.

在为WRAP_CONTENT,同样的输出API2.2和异常抛出设置为:产生的原因:java.lang.UnsupportedOperationException:无法转换为维度:类型= 0×10

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

推荐答案

是的,它是可能的。您可以以这种方式通过样式做到这一点:

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>

和使用它:

 <item name="titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
 <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>

这篇关于可以改变文字大小/颜色动作条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆