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.
Action Bar icon not showing in android action bar
update your acbar.xml as the following:
EDIT:Code
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/home1"
android:orderInCategory="0"
android:icon="@drawable/home_icon"
android:title="Navigate to Home"
app:showAsAction="always"/>
</menu>
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.
Related Topics
How to Capture Image from Custom Cameraview in Android
Difference Between Build.Gradle (Project) and Build.Gradle (Module)
How to Perform a Fade Animation on Activity Transition
How to Encrypt/Decrypt String in Android
Caused By: Java.Lang.Outofmemoryerror: Bitmap Size Exceeds Vm Budget
Rawquery(Query, Selectionargs)
How to Request Root Access in Android
How to Fix "Failed to Sync Vcpu Reg" Error
Interstitial Admob Ads: "Illegalstateexception: Only Fullscreen Activities Can Request Orientation"
How to Notify Users About an Android App Update
Android Mapview -Setting Zoom Automatically Until All Itemizedoverlay's Are Visible
Insertion of Thousands of Contact Entries Using Applybatch Is Slow
View with Horizontal and Vertical Pan/Drag and Pinch-Zoom
Android: Adb Pull File on Desktop