ActionBar/ActionBarSherlock中的自定义图像而不是徽标

Car*_*los 7 android image graphical-logo actionbarsherlock android-actionbar

如何将ActionBar的默认徽标图标更改为自定义图像?类似于它在Whatsapp上的工作方式?Whatsapp自定义图像作为徽标

Pan*_*mar 3

ActionBar 使用清单的android:logo属性(如果提供)。这使您可以为图标(启动器)和徽标(ActionBar 等)使用单独的可绘制资源。


所以你应该将此标签添加到清单中,例如..

<application
    android:logo="@drawable/custom_image"
Run Code Online (Sandbox Code Playgroud)

更新 :

您可以用于ActionBar.setLogo()运行时。有两个版本setLogo(int resId)setLogo(Drawable logo)

阅读在 XML 中为 ActionBar 定义自定义徽标(与徽标不同)?这也将帮助您定义一些样式。