Nick
Nick

Reputation: 1340

Android 4.1 Jellybean drawable on ImageButton not showing

I have an ImageButton such as this:

<ImageButton android:id="@+id/donateButton"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:layout_marginRight="1dp"
           android:src="@drawable/donate"
           android:contentDescription="@string/donate"
           />

Where @drawable/donate points to a donate.gif On older Android versions (1.5, 1.6, 2.X) this image shows up. Anyone having similar issues or have a solution?

Upvotes: 0

Views: 935

Answers (2)

Oliver
Oliver

Reputation: 1279

The correct answer would be: Because 4.1 has a bug in GIF support. I experienced the same error message in one of my apps on the Nexus 7.

This already got reported in http://code.google.com/p/android/issues/detail?id=35285

The given and accepted answer "change to png" may sound valid and help, but still is a workaround. As long as the docs state that GIF is supported format, even if discouraged, it is expected to work.

Still, most simple GIF usually are much more smaller in footprint compared to their (optimized) PNG version. For me, this bug-forced conversion adds another 200k, thats 20% of the whole app size. Some developers still care about the apk footprint.

To make the answer complete, so others may find it:

09-14 02:45:43.873: E/OpenGLRenderer(12425): Cannot generate texture from bitmap

Upvotes: 0

petey
petey

Reputation: 17170

change your graphic from GIF to png.

Gif is not recommended, see : http://developer.android.com/guide/topics/resources/drawable-resource.html#Bitmap

Upvotes: 3

Related Questions