定制的Android行动起来吧 [英] Customize android action bar
问题描述
我试图创建一个新的主题,自定义操作栏:
<资源>
<样式名称=Theme.Shappy.Red父=Theme.Sherlock.Light>
<项目名称=机器人:actionBarStyle> @风格/ ActionBar.Shappy.Red< /项目>
...
... [some_other_customizations]
< /风格>
<! - 行动起来吧 - >
<样式名称=ActionBar.Shappy.Red父=@风格/ Widget.Sherlock.Light.ActionBar.Solid>
<项目名称=机器人:背景>#ffb70000< /项目>
<项目名称=机器人:titleTextStyle> @风格/ ActionBar.Title.Shappy.Red< /项目>
< /风格>
<! - 操作栏的文本 - >
<样式名称=ActionBar.Title.Shappy.Red父=@风格/ TextAppearance.Sherlock.Widget.ActionBar.Title>
<项目名称=机器人:文字颜色>#ddffffff< /项目>
< /风格>
< /资源>
正如你所看到的,我使用的是福尔摩斯。这code正常工作的API级别14,但它并不适用于API级别10工作,我仍然看到全息光一样行动起来吧。 我想是因为[some_other_customizations]正确应用的code是正确的。 你有什么建议吗?谢谢你。
<项目名称=机器人:actionBarStyle> @风格/ ActionBar.Shappy.Red< /项目>
和一切与机器人:
它的前方适用于默认动作条。你必须把它放到你的风格,以及:
<项目名称=actionBarStyle> @风格/ ActionBar.Shappy.Red< /项目>
这将覆盖ABS的风格。 所以,你的风格应该像这样,才能在API级别13 LT工作;
<样式名称=Theme.Shappy.Red父=Theme.Sherlock.Light>
<项目名称=机器人:actionBarStyle> @风格/ ActionBar.Shappy.Red< /项目>
<项目名称=actionBarStyle> @风格/ ActionBar.Shappy.Red< /项目>
< /风格>
<! - 行动起来吧 - >
<样式名称=ActionBar.Shappy.Red父=@风格/ Widget.Sherlock.Light.ActionBar.Solid>
<项目名称=机器人:背景>#ffb70000< /项目>
<项目名称=背景>#ffb70000< /项目>
<项目名称=机器人:titleTextStyle> @风格/ ActionBar.Title.Shappy.Red< /项目>
<项目名称=titleTextStyle> @风格/ ActionBar.Title.Shappy.Red< /项目>
< /风格>
<! - 操作栏的文本 - >
<样式名称=ActionBar.Title.Shappy.Red父=@风格/ TextAppearance.Sherlock.Widget.ActionBar.Title>
<项目名称=机器人:文字颜色>#ddffffff< /项目>
<项目名称=文字颜色>#ddffffff< /项目>
< /风格>
I'm trying to create a new theme and customize the action bar:
<resources>
<style name="Theme.Shappy.Red" parent="Theme.Sherlock.Light">
<item name="android:actionBarStyle">@style/ActionBar.Shappy.Red</item>
...
... [some_other_customizations]
</style>
<!-- Action bar -->
<style name="ActionBar.Shappy.Red" parent="@style/Widget.Sherlock.Light.ActionBar.Solid">
<item name="android:background">#ffb70000</item>
<item name="android:titleTextStyle">@style/ActionBar.Title.Shappy.Red</item>
</style>
<!-- Action bar text -->
<style name="ActionBar.Title.Shappy.Red" parent="@style/TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#ddffffff</item>
</style>
</resources>
As you can see, I'm using Sherlock. This code works fine for API level 14, but it doesn't work for API level 10. I still see the Holo light like action bar. I think the code is correct because [some_other_customizations] are applied correctly. Do you have any suggestion? Thanks.
<item name="android:actionBarStyle">@style/ActionBar.Shappy.Red</item>
and everything else with "android:
" infront of it applies to the default actionbar. You have to put this in your styles as well:
<item name="actionBarStyle">@style/ActionBar.Shappy.Red</item>
This overrides the styles of the ABS. So your Styles should look like this in order to work in API Levels 13<:
<style name="Theme.Shappy.Red" parent="Theme.Sherlock.Light">
<item name="android:actionBarStyle">@style/ActionBar.Shappy.Red</item>
<item name="actionBarStyle">@style/ActionBar.Shappy.Red</item>
</style>
<!-- Action bar -->
<style name="ActionBar.Shappy.Red" parent="@style/Widget.Sherlock.Light.ActionBar.Solid">
<item name="android:background">#ffb70000</item>
<item name="background">#ffb70000</item>
<item name="android:titleTextStyle">@style/ActionBar.Title.Shappy.Red</item>
<item name="titleTextStyle">@style/ActionBar.Title.Shappy.Red</item>
</style>
<!-- Action bar text -->
<style name="ActionBar.Title.Shappy.Red" parent="@style/TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#ddffffff</item>
<item name="textColor">#ddffffff</item>
</style>
这篇关于定制的Android行动起来吧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!