[android] Android: How to change the ActionBar "Home" Icon to be something other than the app icon?

My application's main icon consists of two parts in one image: a logo and a few letters below it. This works well for the launcher icon for the app, but when the icon appears on the left edge of the ActionBar, the letters get cut off and it doesn't look good.

I would like to provide the ActionBar with a separate version of the icon, with only the "logo" part and not the letters beneath it, but so far have been coming up empty. I honestly can't find any answer to this, and I can't even find the question itself anywhere.

This question is related to android android-3.0-honeycomb android-actionbar

The answer is


If you are using AppCompat, the only way to set the ActionBar icon on devices running Gingerbread (API 10) or below is by setting the android:icon attribute in every Activity in your manifest or setting the drawable programatically.

<manifest>
    <application>
        ...
        <activity android:name="com.your.ActivityName"
            ...
            android:icon="@drawable/ab_logo"/>
        ...
   </application>
</manifest>

Update: Be warned however that the application icon will be overridden if you set the android:icon attribute on the launch Activity. The only work around I know of is to have a splash or dummy Activity which then launches your main Activity.


Please Try, if use "extends AppCompatActivity" and present actionbar.

 ActionBar eksinbar=getSupportActionBar();
if (eksinbar != null) {
    eksinbar.setDisplayHomeAsUpEnabled(true);
    eksinbar.setHomeAsUpIndicator(R.mipmap.imagexxx);
}

Please try this line

getSupportActionBar().setHomeAsUpIndicator(R.drawable.back_arrow);

Inspired by TheIT, I just got this to work by manipulating the manifest file but in a slightly different fashion. Set the icon in the application setting so that the majority of the activities get the icon. On the activity where you want to show the logo, add the android:logo attribute to the activity declaration. In the following example, only LogoActivity should have the logo, while the others will default to icon.

<application
    android:name="com.your.app"
    android:icon="@drawable/your_icon"
    android:label="@string/app_name">

    <activity
        android:name="com.your.app.LogoActivity"
        android:logo="@drawable/your_logo"
        android:label="Logo Activity" >

    <activity
        android:name="com.your.app.IconActivity1"
        android:label="Icon Activity 1" >

    <activity
        android:name="com.your.app.IconActivity2"
        android:label="Icon Activity 2" >

</application>

Hope this helps someone else out!


Might wanna check this, got everything you need for your app icons

http://developer.android.com/guide/practices/ui_guidelines/icon_design.html

update

I think by default it uses your launcher icon... Your best bet is to create a separate image... Designed for the action bar and using that. For that check: http://developer.android.com/guide/topics/ui/actionbar.html#ActionItems


creating logo

in folders "drawable-..." create in all of them logo.png . The location of the folders: [YOUR APP]\app\src\main\res

In AndroidManifest.xml add line: android:logo="@drawable/logo"

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

that's it.


In AndroidManifest.xml:

<application
    android:icon="@drawable/launcher"
    android:label="@string/app_name"
    android:name="com..."
    android:theme="@style/Theme">...</Application>

In styles.xml: (See android:icon)

<style name="Theme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/ActionBar</item>
</style>
<style name="ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:icon">@drawable/icon</item>
</style>

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-3.0-honeycomb

Why fragments, and when to use fragments instead of activities? How to implement the Android ActionBar back button? How to hide action bar before activity is created, and then show it again? Android replace the current fragment with another fragment getActionBar() returns null Fragments onResume from back stack How to set a Fragment tag by code? Android: How to change the ActionBar "Home" Icon to be something other than the app icon? ActionBar text color Unable to resolve host "<insert URL here>" No address associated with hostname

Examples related to android-actionbar

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? Failed to load AppCompat ActionBar with unknown error in android studio Android transparent status bar and actionbar ActionBarActivity is deprecated Manage toolbar's navigation and back button from fragment in android setSupportActionBar toolbar cannot be applied to (android.widget.Toolbar) error How to use SearchView in Toolbar Android How to get Toolbar from fragment? Display Back Arrow on Toolbar Remove title in Toolbar in appcompat-v7