【发布时间】:2013-04-24 10:41:48
【问题描述】:
有没有办法改变 ActionBar 的标题和副标题的大小/颜色?
我正在使用 ActionBarSherlock 来桥接低版本和高版本。 ActionBarSherlock 提供了在 SherlockActionBarCompat 中自定义文本样式的方法,但在 SherlockActionBarNative 中似乎没有办法。
编辑: 由 Jake 添加并由作者删除
编辑: 接近解决方案:
<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 的作者 Jake 的帮助。
现在它几乎完成了,除了 actionBarSize 只能从相当多的试验中估计出一个近似的绝对尺寸(我的应用程序为 60dp); wrap_content 导致 API2.2 扩展整个屏幕并在解析 xml 时抛出 API4.2.2 异常。
加法:
当actionBarSize设置为0dp时,输出为(http://i.stack.imgur.com/xX4E1.png,信誉低,直接发图):左边API2.2,动作条占满全屏,没有内容,右边API4.2.2,有内容没有操作栏。
当设置为 wrap_content 时,API2.2 的输出相同,并且抛出的异常为:Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x10
【问题讨论】:
-
titleTextStyle属性采用您从actionBarStyle引用的样式。
标签: android text size actionbarsherlock