简体   繁体   中英

Application icon doesn't show up in Android action bar

I'm trying to do an application using support libraries, and I tried to add an action bar to it. The action bar works just fine, but it doesn't show the company icon. I tried specifying icon and logo, in the manifest and programatically, but still, nothing works.

In my code, I have this:

    //Actionbar setup
    mActionBar = getSupportActionBar();
    mActionBar.setIcon(res.getDrawable(R.drawable.ic_launcher));
    mActionBar.setLogo(res.getDrawable(R.drawable.ic_launcher));
    mActionBar.setTitle("");

    //Tabs setup
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    tabConoce = mActionBar.newTab().setText(res.getString(R.string.conoce));
    tabExperimenta = mActionBar.newTab().setText(res.getString(R.string.experimenta));         
    frgConoce = new TabConoce();
    frgExperimenta = new TabExperimenta();
    tabConoce.setTabListener(new GeaTabListener(frgConoce));
    tabExperimenta.setTabListener(new GeaTabListener(frgExperimenta));
    mActionBar.addTab(tabConoce);
    mActionBar.addTab(tabExperimenta);

And in the manifest, I have this:

<application
    android:icon="@drawable/ic_launcher"
    android:logo="@drawable/ic_launcher"
    ... >
    ...
</application>

Please help.

This works with the native action bar on Android 5.0 to display an icon:

getActionBar().setLogo(R.drawable.ic_launcher);
getActionBar().setDisplayShowHomeEnabled(true);
getActionBar().setDisplayUseLogoEnabled(true);

Whether it works with the appcompat-v7 action bar, I cannot say, as I have not yet tried that.

not use com.android.support:appcompat-v7:22.0.0

try use:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.0.0'
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM