I created an action bar icon for an Android app I’m working on and it seems to downscale my icon.
The thing is, it isn’t a square icon. The width is greater than the height.
Do I really HAVE to provide square icons or is there a workaround for this?
I don’t really want to ditch my icons just because of this…
An applications logo is typically wider than it’s icon and resizes as necessary to fit the height of the action bar. I believe this is what you’re looking for.
By default, the system uses your application icon in the action bar, as specified by the icon attribute in the or element. However, if you also specify the logo attribute, then the action bar uses the logo image instead of the icon.
Source: http://developer.android.com/guide/topics/ui/actionbar.html#Adding
setDisplayUseLogoEnabled() Enables the use of an alternative image (a “logo”) in the Action Bar, instead of the default application icon. A logo is often a wider, more detailed image that represents the application. When this is enabled, the system uses the logo image defined for the application (or the individual activity) in the manifest file, with the android:logo attribute. The logo will be resized as necessary to fit the height of the Action Bar. (Best practice is to design the logo at the same size as your application icon.)
Source: http://developer.android.com/guide/topics/ui/actionbar.html#Style
To replace the icon with a logo, specify your application logo in the manifest file with the android:logo attribute, then call setDisplayUseLogoEnabled(true) in your activity.
Source: http://developer.android.com/sdk/android-3.0.html#api
Also see https://stackoverflow.com/questions/6735649/android-icon-vs-logo
In the case of the Action Items instead of the activity icons, it’s a fairly simple work around and involves using Action Views rather than Action Items.
An action view is a widget that appears in the action bar as a substitute for an action button. An action view provides fast access to rich actions without changing activities or fragments, and without replacing the action bar.
Source: http://developer.android.com/guide/topics/ui/actionbar.html#ActionView
To do what you’re asking all you need to do is add an ImageButton to your action bar as an Action View.
2