Skip to content Skip to sidebar Skip to footer

Define Custom Logo For Actionbar (different Than Logo) In Xml?

I want to make a Actionbar_style.xml for my app and I would like to use a logo, different than my app logo / icon. How to change it programmatcially is clear: Change logo that appe

Solution 1:

Just set a value for the android:icon attribute

<stylename="AppTheme"parent="@android:style/Theme.Holo.Light"><itemname="android:actionBarStyle">@style/AppTheme.ActionBarStyle</item></style><stylename="AppTheme.ActionBarStyle"parent="android:style/Widget.Holo.Light.ActionBar"><itemname="android:background">@drawable/actionbar_background</item><itemname="android:titleTextStyle">@style/AppTheme.ActionBar.TitleTextStyle</item><itemname="android:icon">@drawable/ic_home</item><itemname="android:indeterminateProgressStyle">@style/IndeterminateProgress</item></style>

Solution 2:

You don't style the logo in the your style XML, you simply use android:logo in your Manifest, then use setDisplayUseLogoEnabled() to set it in the ActionBar. Here's a project, from Google, that shows you how to switch between the two. http://code.google.com/p/styled-action-bar/

Solution 3:

Sounds like you need to use a custom layout for the action bar, that way you can define a whatever you want for logo image.

Action bar / ActionbarSherlock style

<stylename="ActionBar"parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse"><itemname="displayOptions">showCustom</item><itemname="android:displayOptions">showCustom</item><itemname="customNavigationLayout">@layout/action_bar_home_icon_default</item><itemname="android:customNavigationLayout">@layout/action_bar_home_icon_default</item></style>

@layout/action_bar_home_icon_default is your custom layout, with your custom logo

Solution 4:

Yes. You may set different logo for different activities. Here is the sample code in manifest file.

<activity
   android:name="MyActivity"
   ***android:icon="@drawable/logo"***            
   android:label="@string/app_name"
   android:configChanges="orientation"           
   android:screenOrientation="portrait" />

Hope this help. Cheers!

Post a Comment for "Define Custom Logo For Actionbar (different Than Logo) In Xml?"