Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't set home logo #33

Closed
widi opened this issue Jul 8, 2011 · 2 comments
Closed

Can't set home logo #33

widi opened this issue Jul 8, 2011 · 2 comments

Comments

@widi
Copy link

widi commented Jul 8, 2011

I want to display the action-bar such that I have my logo (png) and the title right next to it (like in the referenced app STHLM Traveling - Journey planner for Stockholm Public Transport). I am using this code:

    ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
    getMenuInflater().inflate(R.menu.main_menu_actionbar, actionBar.asMenu());              
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setHomeLogo(R.drawable.icon); 

The main_manu_actionbar.xml looks like this:

For some reason, the logo will never show up. Only the title appears on the left side and the action menu menu_report on the right side. Where is the logo?? Thanks.

@johannilsson
Copy link
Owner

Hey,

The STHLM Traveling app logo is set through the menu xml by referencing an id with @id/actionbar_item_home. Note that the id is referenced without a +. This is because that id is created in the action bar. Whenever the action bar finds an action item with that id that action item is set as the home action.

<item
    android:id="@id/actionbar_item_home"
    android:icon="@drawable/ic_logo"/>

You can also specify a home logo, by calling setHomeLogo as in your example. I believe that you also have to call setDisplayShowHomeEnabled.

This is how we configured the action bar for the dashboard in the Voddler app;

ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setHomeLogo(R.drawable.logo_title);
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
getMenuInflater().inflate(R.menu.actionbar_dashboard, actionBar.asMenu());

I'm not sure if the call to setDisplayShowTitleEnabled is necessary though.

@widi
Copy link
Author

widi commented Jul 9, 2011

Hey! Thanks. It works now. I didn't know I have to set both

actionBar.setDisplayUseLogoEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);

for the logo to show. Great widget anyways! Thanks!

@widi widi closed this as completed Jul 9, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants