Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom image instead of logo in ActionBar/ActionBarSherlock

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

like image 439
Carlos Avatar asked Oct 04 '13 02:10

Carlos


2 Answers

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 :

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

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

like image 127
Pankaj Kumar Avatar answered Nov 03 '22 22:11

Pankaj Kumar


The simplest technique is to use setIcon(R.drawable.icon_name) Similarly you can do with the Title and you can also set the date in the action bar subtitle.

ActionBar ab= getActionBar();
ab.setTitle("Aries");
ab.setSubtitle(dateFormat.format(date));
ab.setIcon(R.drawable.aries3d);
like image 43
ashim888 Avatar answered Nov 03 '22 22:11

ashim888