No App Icon on Actionbar

No App Icon on ActionBar

As of AppCompat version 21, the Action Bar follows the material design guidelines and uses a Toolbar:

  • A title and subtitle. The title should be a signpost for the Toolbar's current position in the navigation hierarchy and the content contained there. The subtitle, if present should indicate any extended information about the current content. If an app uses a logo image it should strongly consider omitting a title and subtitle.

In modern Android UIs developers should lean more on a visually distinct color scheme for toolbars than on their application icon. The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.

However, if you want an application icon, setLogo() is the correct method.

The application icon does not show on action bar

You are using the AppCompat version 21+ and it is normal.

The Action Bar follows the material design guidelines and uses a Toolbar.
As you can read here:

The use of application icon plus title as a standard layout is
discouraged on API 21 devices and newer.

If you would like an application icon (but I discourage it), you can use the method setLogo().

Something like this:

ActionBar actionBar = getSupportActionBar();
actionBar.setLogo(R.drawable.my_logo);
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);

Application's icon not displayed in ActionBar

Your activity must extend ActionBarActivity.

For example:

public class MainActivity extends ActionBarActivity
{
...
}

Or try this in your activity:

ActionBar actionBar = getActionBar();
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
actionBar.setIcon(R.drawable.ic_launcher);

You will have to use getSupportActionBar() if using the support library.

No App Icon on ActionBar

As of AppCompat version 21, the Action Bar follows the material design guidelines and uses a Toolbar:

  • A title and subtitle. The title should be a signpost for the Toolbar's current position in the navigation hierarchy and the content contained there. The subtitle, if present should indicate any extended information about the current content. If an app uses a logo image it should strongly consider omitting a title and subtitle.

In modern Android UIs developers should lean more on a visually distinct color scheme for toolbars than on their application icon. The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.

However, if you want an application icon, setLogo() is the correct method.

No application icon in Action Bar

If you're using the appcompat-v7 support library for support with Android 5.0, there would not be an action bar logo because of the new design concept.

Android - How do i hide the app icon on action bar

I would suggest you use a style for your action bar.

Within your styles.xml file under your values folder you can edit it such that you AppTheme uses a specific style for your action bar. Within that specific style you can declare your icon attribute. This let's the action bar know from the get go that you have a specific icon for it and will show it to begin with eliminating the temporary pause.

styles.xml

<resources>

<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="actionBarStyle">@style/MyActionBarStyle</item>
</style>

<style name="MyActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="icon">@android:color/transparent</item>
</style>
</resources>

As you can see in the style "AppTheme" I add:

<item name="actionBarStyle">@style/MyActionBarStyle</item>

This states that I want my app to take into account a custom style for the action bar called "MyActionBarStyle"

You can also see I that I declare that style with:

<style name="MyActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="icon">@android:color/transparent</item>
</style>

In this declaration I can set the icon to be a drawable or color (as we did in this instance). Hope this helps.

Also this example assumes you're using the support library. If not then just make sure you replace 'AppCompat' with 'Holo', 'icon' with 'android:icon', and 'actionBarStyle' with 'android:actionBarStyle'. I learned that the hard way :)

App icon is not visible on Actionbar in android Lollipop and above

In the Material theme (and AppCompat version 21 which is based on it), the Action Bar follows the material design guidelines and uses a Toolbar:

  • A title and subtitle. The title should be a signpost for the Toolbar's current position in the navigation hierarchy and the content contained there. The subtitle, if present should indicate any extended information about the current content. If an app uses a logo image it should strongly consider omitting a title and subtitle.

In modern Android UIs developers should lean more on a visually distinct color scheme for toolbars than on their application icon. The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.

However, if you want an application icon, setLogo() is the correct method.



Related Topics



Leave a reply



Submit