Renato Lochetti
Renato Lochetti

Reputation: 4576

ActionBarSherlock Item Icon strange width with Android 4.3

I`m developing an App using ActionBarSherlock

One of the items in the menu is a rectangular image. See it`s xml:

<item
    android:id="@+id/kapturar_action"
    android:showAsAction="always"
    android:icon="@drawable/camera_action_icon"
    android:title="@string/kapturar" />
<item

So far so good. The problem is that the SDK 4.3 appears to accept only square images (This is my supposition, i`m not sure of that) and the icon shows in a strange fashion preserving what appears to be a "max width" property.

See the printscreens

Android 2.2 - Simulator:

Android 2.2

Android 4.1.2 - Samsung Galaxy S3 Mini:

Android 4.1.2

Android 4.3 - Nexus 4:

Android 4.3

I double checked the drawables and I think that everything is right. I have defined the MDPI, HDPI and XHDPI images.

Can anybody affirm that is impossible to use rectangular drawables in the menu`s item? Is there a way to fix the problem in the Android 4.3 preserving the backward-compatible?

Upvotes: 13

Views: 371

Answers (3)

galex
galex

Reputation: 3319

Action Bar Sherlock is now deprecated as Google released their own Action Bar compatibility library.

I strongly recommend to switch to that official library, I guess/hope your problem won't appear there.

Upvotes: 4

Sergey  Pekar
Sergey Pekar

Reputation: 8745

Try to put your drawable into another folder. I mean if it is in drawable-xhdpi folder put it to drawable-hdpi (or other). Sometimes it solves the problem with resizing images from resources

Upvotes: 0

mig35
mig35

Reputation: 1442

You can simply use compatibility version of ActionBar. This is not very good answer but it will help you.

To make it just comment line

registerImplementation(ActionBarSherlockNative.class);

In ActionBarSherlock class.

Moreover after this you can edit sources, resources in ActionBarSherlock and they will look the same on Android 2.3 and Android 4.0+ devices.

Upvotes: 0

Related Questions