应用程序兼容性动作条V21的应用程序图标不显示 [英] App compat actionbar v21 app icon is not showing

查看:189
本文介绍了应用程序兼容性动作条V21的应用程序图标不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我升级到avtionbar应用程序兼容性V21材料设计的目的。

I upgraded to avtionbar app compat v21 for material design purpose.

不过,我认为,它没有出现在动作条和导航菜单和后退按钮的应用程序图标占用了过多的空间比较老appcompat库。

But I observed that its not showing the app icon in actionbar and navigation menu and back button is taking more space compare to old appcompat libs.

有任何一个面对这个问题?我搜索了很多,但没有发现任何有用的。

Have any one faced this issue? I searched a lot but did not found anything useful.

下面线也不能正常工作。

Below line is also not working.

getSupportActionBar().setLogo(R.drawable.ic_launcher);

我使用的样式动作条这就好比

I am using style for actionbar which is like

<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:icon">@drawable/ic_action_bar</item>
        <item name="android:background">@drawable/action_bar_bg</item>
        <item name="android:windowContentOverlay">@null</item>
        <!-- Support library compatibility -->
        <item name="background">@drawable/action_bar_bg</item>
</style>

我所知道的其他解决方案类似的工具栏。但我在释放中,由于时间的限制,我在寻找一些快速的解决方案,如果有的话。添加工具栏将需要更多的时间。

I am aware of other solution like Toolbar. But I am in middle of release and due to time constraint I am looking for some quick solution if available. Adding a Toolbar will require more time.

推荐答案

的setIcon / setLogo 如果设置方法仅适用 DisplayOptions 尝试这一点 -

setIcon/setLogo method will only work if you have set DisplayOptions Try this -

actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
actionBar.setIcon(R.drawable.ic_launcher);

您还可以设置选项来显示的LOGO(刚加入恒 ActionBar.DISPLAY_USE_LOGO )。更多信息 - <一个href="http://developer.android.com/reference/android/support/v7/app/ActionBar.html#setDisplayOptions(int,%20int)">displayOptions

You can also set options for displaying LOGO(just add constant ActionBar.DISPLAY_USE_LOGO). More information - displayOptions

这篇关于应用程序兼容性动作条V21的应用程序图标不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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