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

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

问题描述

我想改变了图标与应用下面的样式给我的活动,但它不工作,但是我还是默认的黑色'<图标。

任何人都可以找出是什么在这里失踪?

 <样式名称=AppTheme.ActionBar父=@风格/ Theme.Sherlock.Light>
    <项目名称=actionBarStyle> @风格/ actionBarStyle< /项目>
    <项目名称=机器人:actionBarStyle> @风格/ actionBarStyle< /项目>
< /风格>

<样式名称=actionBarStyle父=@风格/ Widget.Sherlock.Light.ActionBar.Solid>
    <项目名称=机器人:背景> @可绘制/ header_bar< /项目>
    <项目名称=背景> @可绘制/ header_bar< /项目>

    <项目名称=机器人:homeAsUpIndicator> @可绘制/ up_indicator< /项目>
    <项目名称=homeAsUpIndicator> @可绘制/ up_indicator< /项目>
    <项目名称=机器人:displayOptions> homeAsUp | showHome< /项目>
    <项目名称=displayOptions> homeAsUp | showHome< /项目>

< /风格>
 

解决方案

如果我没有记错,我通过移动工作解决此问题您应该移动安卓homeAsUpIndicator homeAsUpIndicator 元素融入主旋律声明。换句话说,试试:

 <样式名称=AppTheme.ActionBar父=@风格/ Theme.Sherlock.Light>
    <项目名称=actionBarStyle> @风格/ actionBarStyle< /项目>
    <项目名称=机器人:actionBarStyle> @风格/ actionBarStyle< /项目>
    <项目名称=机器人:homeAsUpIndicator> @可绘制/ up_indicator< /项目>
    <项目名称=homeAsUpIndicator> @可绘制/ up_indicator< /项目>
< /风格>

<样式名称=actionBarStyle父=@风格/ Widget.Sherlock.Light.ActionBar.Solid>
    <项目名称=机器人:背景> @可绘制/ header_bar< /项目>
    <项目名称=背景> @可绘制/ header_bar< /项目>
    <项目名称=机器人:displayOptions> homeAsUp | showHome< /项目>
    <项目名称=displayOptions> homeAsUp | showHome< /项目>
< /风格>
 

不知道我是否也有走高的 displayOptions ,但你可能想给一个去得在上述情况下,不工作的时候了

顺便说一句,我发现命名的样式 AppTheme.ActionBar ,然后从 Theme.Sherlock.Light 继承相当混乱。如果它是一个特定的ActionBar风格,我会一直期待像 Widget.Holo.Light.ActionBar (或任何其他部件的样式)作为母体。如果这是你的主旋律,我会相应地命名。截至当然给你。


编辑:杰克的评论后,更新的答案

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>

解决方案

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>

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.

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.


Edit: Updated answer after Jake's comment.

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

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