Sartheris Stormhammer
Sartheris Stormhammer

Reputation: 2564

Logo in ActionBar instead of text

I want to put a picture on my action bar, instead of the text (No, I am not using action bar sherlock), and if possible for the action bar to be transparrent AND with detectable height (I have done transparent action bar before, but you can't get its height programatically this way). It should be in styles somehow, not programatically. Right now I have this styles.xml and it does absolutely nothing...

<resources>

<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/AppTheme.ActionBarStyle</item>
</style>

<style name="AppTheme.ActionBarStyle" parent="android:style/Widget.Holo.Light.ActionBar">
    <item name="android:icon">@drawable/img_ab_youlocal_logo</item>
</style>

P.S. YES, I have searched before asking, the other asnwers were not helpful.

Upvotes: 2

Views: 1036

Answers (1)

throws_exceptions_at_you
throws_exceptions_at_you

Reputation: 1746

If you are using an api < 21 you could do something similar this:

ActionBar actionbar = getActionBar();         
actionbar.setDisplayShowCustomEnabled(true);
actionbar.setCustomView(R.layout.someLayoutfile);

You may have to this before the Parent View gets inflated / set via setContentView();

Also in api > 11 you have a logo attribute:

Using a logo instead of an icon

By default, the system uses your application icon in the action bar, as specified by the icon attribute in the

<application> or <activity>

element. However, if you also specify the logo attribute, then the action bar uses the logo image instead of the icon.

A logo should usually be wider than the icon, but should not include unnecessary text. You should generally use a logo only when it represents your brand in a traditional format that users recognize. A good example is the YouTube app's logo—the logo represents the expected user brand, whereas the app's icon is a modified version that conforms to the square requirement for the launcher icon.

Upvotes: 1

Related Questions