Application icon does not appear in Android action bar

I am trying to make an application using support libraries, and I tried to add an action bar to it. The action bar works fine, but the company icon is not displayed. I tried to specify the icon and logo in the manifest and programmatically, but still nothing works.

In my code, I have the following:

//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.

+5
source share
2 answers

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

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

Does it work with the appcompat-v7 action appcompat-v7 , I cannot say, since I have not tried this yet.

+3
source

don't use com.android.support:appcompat-v7:22.0.0

try using:

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

Source: https://habr.com/ru/post/1207329/


All Articles