Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show both logo and app name in action bar android

i have set these two lines of code to display both logo and app name in action bar, but only app name appears, like in the screenshot:

enter image description here

actionBar.setDisplayUseLogoEnabled(true);
actionBar.setLogo(R.drawable.icon);

Do i need other code to show both? I have added this in manifest but same result:

<application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:logo="@drawable/icon"

I'm working on a Tabbed activity with action bar.

Can you help me? Thank you

like image 995
slash89mf Avatar asked Nov 21 '14 20:11

slash89mf


People also ask

What is the difference between toolbar and action bar in Android?

What is the difference between the toolbar and the action bar? The most obvious difference between the two is the updated visual design of the toolbar. The toolbar no longer includes an icon on the left side and decreases some of the spacing between the action items on the right side.

How do you add action items to the action bar in Android?

All action buttons and other items available in the action overflow are defined in an XML menu resource. To add actions to the action bar, create a new XML file in your project's res/menu/ directory. The app:showAsAction attribute specifies whether the action should be shown as a button on the app bar.

How do you display action bar back button on all versions of Android?

Show back button using actionBar. setDisplayHomeAsUpEnabled(true) this will enable the back button. Custom the back event at onOptionsItemSelected. This will enable the back function to the button on the press.


1 Answers

Solved adding

    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setLogo(R.drawable.icona);
    getSupportActionBar().setDisplayUseLogoEnabled(true);

Using logo in actionbar is disabled by default in Android 5.0 Lollipop.

like image 83
slash89mf Avatar answered Nov 07 '22 17:11

slash89mf