Ogen
Ogen

Reputation: 6709

Action bar icon size inconsistency

I have an action bar with 4 buttons defined as follows...

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/actionBarNew"
        android:showAsAction="always"
        android:scaleType="fitXY"
        android:icon="@drawable/ic_action_new"
        style="@style/ActionButtonStyle"
        android:title="new" />
    <item android:id="@+id/actionBarSave"
        android:showAsAction="always"
        android:scaleType="fitXY"
        android:icon="@drawable/ic_action_save"
        style="@style/ActionButtonStyle"
        android:title="save" />
    <item android:id="@+id/actionBarLoad"
        android:showAsAction="always"
        android:icon="@drawable/ic_action_load"
        android:scaleType="fitXY"
        style="@style/ActionButtonStyle"
        android:title="load" />
    <item android:id="@+id/actionBarDelete"
        android:showAsAction="always"
        android:scaleType="fitXY"
        style="@style/ActionButtonStyle"
        android:icon="@drawable/ic_action_delete"
        android:title="delete" />
</menu>

I used a Actionbar icon generator to generate different sized icons and put them in their respective folders.

The problem is, the delete icon looks smaller than the rest of them. Here is a screenshot of my actionbar.

enter image description here

Any ideas why this is happening?

Upvotes: 0

Views: 966

Answers (1)

Litrik De Roy
Litrik De Roy

Reputation: 1032

It looks like you have created icons with some text in them. The word "Delete" is larger than the 3 other words and my guess is that the action bar icon generator scaled the text to make it fit (because all action bar icons have the same width).

I suggest you remove the android:icon attributes and use android:title instead. That will show pieces of text, without scaling the font size.

Alternatively you can continue to use android:icon but with some real icons (not just text in an image). There are a couple of standard action icons available in the Action Bar Icon Pack and a lot more can be bought at androidicons.com

PS: The android:scaleType attribute is useless on a menu item. The full list of supported attributes is available here

Upvotes: 2

Related Questions