如何在安卓(ActionbarSherlock)自定义动作条? [英] How to customize ActionBar in Android (ActionbarSherlock)?

查看:151
本文介绍了如何在安卓(ActionbarSherlock)自定义动作条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用ActionBarSherlock在我的应用程序提供给其他动作pre蜂窝设备。我想用Light.DarkActionBar主题的,我怎么可以自定义以下的动作条的部分(见图片)

I have used ActionBarSherlock in my application for providing ActionBars to pre honeycomb devices. I want to use Light.DarkActionBar Theme in, How can I customize following for parts of the ActionBar (see image)

  1. 在动作条的背景颜色
  2. 背景图片的动作条标签栏
  3. 在其中重新底线presents选定的标签
  4. 标签之间的分隔符...

我用下面的设置都试过了,虽然我已经取得了一定的成功,但结果却看起来并不如预期,

I have tried using following settings, Though I have achieved some success but the result however doesn't look as expected,

<item name="android:background">@drawable/bg_title_bar</item>
<item name="background">@drawable/bg_title_bar</item>
<item name="actionModeSplitBackground">@drawable/bg_tab_bar</item>
<item name="android:actionModeSplitBackground">@drawable/bg_tab_bar</item>

这是我应该使用其他设置?谢谢!

Which are the other settings that I should use ? Thanks!!

推荐答案

这是我做到了,以防万一有人在今后发生类似的要求。

我下载了从风格Genarator ...解压和内容仔细看一个示例zip文件提出,我需要以下属性,

I downloaded a sample zip file from Style Genarator... Unzipping and a close look on the content suggested that I needed following attributes,

  1. 有关动作条的背景颜色

  1. for Background color of ActionBar

<item name="background">@drawable/title_bg</item>
<item name="android:background">@drawable/title_bg</item>

2。      对背景图像的动作条标签栏

2. for Background Image for ActionBar tab bar

    <item name="backgroundStacked">@drawable/tab_bg</item>
    <item name="android:backgroundStacked">@drawable/tab_bg</item>  

3。 为底线从而重新presents选定的标签

3. for The bottom line which represents the selected tab

               i. I created a style as follows
                    <style name="ActionBar.TabStyle" parent="@style/Widget.Sherlock.Light.ActionBar.TabView">
                    <item name="background">@drawable/ab_tab_indicator</item>
                    <item name="android:background">@drawable/ab_tab_indicator</item>
                </style>
               ii. I used that style in the theme as follows
                 <item name="actionBarTabStyle">@style/ActionBar.TabStyle</item>
                 <item name="android:actionBarTabStyle">@style/ActionBar.TabStyle</item>

4的选项卡之间的分...

4 for The divider between tabs...

在主题我加了两行。

  <item name="actionBarTabBarStyle">@style/My.ActionBar.TabBar</item>
  <item name="android:actionBarTabBarStyle">@style/My.ActionBar.TabBar</item>

<style name="My.ActionBar.TabBar" parent="@android:style/Widget.Holo.ActionBar.TabBar">
    <item name="divider">@drawable/tab_divider</item>
    <item name="android:showDividers">middle</item>
    <item name="android:divider">@drawable/tab_divider</item>
    <item name="android:dividerHeight">24dp</item>
    <item name="android:dividerPadding">8dp</item>
    <!-- <item name="android:background">@drawable/tab_unselected</item> -->
</style>

这篇关于如何在安卓(ActionbarSherlock)自定义动作条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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