在动作条/ ActionBarSherlock自定义图片代替标志 [英] Custom image instead of logo in ActionBar/ActionBarSherlock

查看:178
本文介绍了在动作条/ ActionBarSherlock自定义图片代替标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能改变一个动作条的默认标识图标是一个自定义图像?类似的,因为它的工作原理上的WhatsApp?

How can I change the default logo icon of an ActionBar to be a custom image? Similar as how it works on Whatsapp?

推荐答案

的动作条使用的 Android的:你的清单中的标志的属性,如果已提供。这使您可以使用不同的绘制资源的图标(发射器)和标识(动作条,除其他事项外)。

The ActionBar uses the android:logo attribute of your manifest, if one is provided. That lets you use separate drawable resources for the icon (Launcher) and the logo (ActionBar, among other things).

所以,你应该添加此标记到明显的如..

So you should add this tag into manifest like ..

<application
    android:logo="@drawable/custom_image"

更新:

Update :

您可以使用 ActionBar.setLogo()运行时。两个版本有 setLogo(INT渣油)和<一href="http://developer.android.com/reference/android/app/ActionBar.html#setLogo%28android.graphics.drawable.Drawable%29"相对=nofollow> setLogo(可绘制标志)。

You can use ActionBar.setLogo() for runtime. Two versions are there setLogo(int resId) and setLogo(Drawable logo).

读<一href="http://stackoverflow.com/questions/8728365/define-custom-logo-for-actionbar-different-than-logo-in-xml">Define在XML定制标志的动作条(比标志不同)?这将有助于你还定义了一些样式。

Read Define custom Logo for ActionBar (different than Logo) in XML? which will help you to define some styles also.

这篇关于在动作条/ ActionBarSherlock自定义图片代替标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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