ActionBarSherlock:更改 homeAsUpIndicator 不起作用 [英] ActionBarSherlock: changing homeAsUpIndicator doesn't work

查看:41
本文介绍了ActionBarSherlock:更改 homeAsUpIndicator 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过将以下样式应用于我的活动来更改向上图标,但它不起作用,但我仍然得到默认的黑色<"图标.

I'm want to change the up icon with applying the following style to my activity, but it doesn't work and but I still get the default black '<' icon.

谁能找出这里遗漏了什么?

Can anyone find out what is missing here?

<style name="AppTheme.ActionBar" parent="@style/Theme.Sherlock.Light">
    <item name="actionBarStyle">@style/actionBarStyle</item>
    <item name="android:actionBarStyle">@style/actionBarStyle</item>
</style>

<style name="actionBarStyle" parent="@style/Widget.Sherlock.Light.ActionBar.Solid">
    <item name="android:background">@drawable/header_bar</item>
    <item name="background">@drawable/header_bar</item>

    <item name="android:homeAsUpIndicator">@drawable/up_indicator</item>
    <item name="homeAsUpIndicator">@drawable/up_indicator</item>
    <item name="android:displayOptions">homeAsUp|showHome</item>
    <item name="displayOptions">homeAsUp|showHome</item>

</style>

推荐答案

如果我没记错的话,我通过移动解决了这个问题 你应该移动 android:homeAsUpIndicatorhomeAsUpIndicator 元素进入主题声明.换句话说,尝试:

If I remember correctly, I worked around this issue by moving you should move the android:homeAsUpIndicator and homeAsUpIndicator elements into the main theme declaration. In other words, try:

<style name="AppTheme.ActionBar" parent="@style/Theme.Sherlock.Light">
    <item name="actionBarStyle">@style/actionBarStyle</item>
    <item name="android:actionBarStyle">@style/actionBarStyle</item>
    <item name="android:homeAsUpIndicator">@drawable/up_indicator</item>
    <item name="homeAsUpIndicator">@drawable/up_indicator</item>
</style>

<style name="actionBarStyle" parent="@style/Widget.Sherlock.Light.ActionBar.Solid">
    <item name="android:background">@drawable/header_bar</item>
    <item name="background">@drawable/header_bar</item>
    <item name="android:displayOptions">homeAsUp|showHome</item>
    <item name="displayOptions">homeAsUp|showHome</item>
</style>

不确定我是否还必须将 displayOptions 向上移动,但您可能也想尝试一下,以防上述操作无法立即生效.

Not sure whether I also had to move up the displayOptions, but you may want to give that a go too in case above doesn't work right away.

顺便说一下,我发现命名一个样式 AppTheme.ActionBar 然后从 Theme.Sherlock.Light 继承相当混乱.如果它是特定于 ActionBar 的样式,我会期望像 Widget.Holo.Light.ActionBar(或任何其他小部件样式)作为父项.如果这是您的主题,我会相应地命名.当然取决于你.

By the way, I find naming a style AppTheme.ActionBar and then inheriting from Theme.Sherlock.Light rather confusing. If it were an ActionBar specific style, I would've expected something like Widget.Holo.Light.ActionBar (or any of the other widget styles) as the parent. If it's your main theme, I'd name it accordingly. Up to you of course.

在 Jake 发表评论后更新了答案.

Updated answer after Jake's comment.

这篇关于ActionBarSherlock:更改 homeAsUpIndicator 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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