格调操作栏在Android的蜂窝 [英] Style an Action Bar in Android Honeycomb

查看:102
本文介绍了格调操作栏在Android的蜂窝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过设置主题和风格的操作栏(蜂窝)的背景。你可以用 ActionBar.setBackgroundDrawable(可绘制)做在code,但我无法找到相应的样式属性。

I'd like to set the background of an action bar (Honeycomb) using themes and styles. You can do it in code with ActionBar.setBackgroundDrawable(Drawable), but I can't find the corresponding style attributes.

我已经使用这个主题和风格对我的活动尝试:

I have tried using this theme and style for my Activity:

<style name="Theme.MyApp" parent="android:style/Theme.Holo">
    <item name="android:actionBarStyle">@style/ActionBar</item>
</style>

<style name="ActionBar">
    <item name="android:background">@drawable/action_bar_background</item>
</style>

但是这使背景超过左侧的应用程序图标和标题。右边的菜单图标都很好,背景是在它之下。

but this puts the background over the app icon and title on the left. The menu icons on the right are fine and the background is under it.

所以,反正是有这样做吗?

So is there anyway to do this?

推荐答案

好吧,我理解了它。我需要从基础动作栏样式继承。正确的方式是:

Ok, I figured it out. I needed to inherit from the base action bar style. The correct styles are:

<style name="Theme.MyApp" parent="android:style/Theme.Holo">
    <item name="android:actionBarStyle">@style/ActionBar</item>
</style>

<style name="ActionBar" parent="android:style/Widget.Holo.ActionBar">
    <item name="android:background">@drawable/action_bar_background</item>
</style>

这篇关于格调操作栏在Android的蜂窝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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