简体   繁体   English

ImageButton上的Android 4.1 Jellybean可绘制对象未显示

[英]Android 4.1 Jellybean drawable on ImageButton not showing

I have an ImageButton such as this: 我有一个像这样的ImageButton:

<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. @ drawable / donate指向donate.gif的位置。在较旧的Android版本(1.5、1.6、2.X)上,将显示此图像。 Anyone having similar issues or have a solution? 有类似问题或解决方案的人吗?

change your graphic from GIF to png. 将图形从GIF更改为png。

Gif is not recommended, see : http://developer.android.com/guide/topics/resources/drawable-resource.html#Bitmap 不建议使用Gif,请参阅: http : //developer.android.com/guide/topics/resources/drawable-resource.html#Bitmap

The correct answer would be: Because 4.1 has a bug in GIF support. 正确的答案是:因为4.1在GIF支持中存在错误。 I experienced the same error message in one of my apps on the Nexus 7. 我在Nexus 7上的一个应用中遇到了相同的错误消息。

This already got reported in http://code.google.com/p/android/issues/detail?id=35285 这已经在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. 给定和接受的答案“更改为png”可能听起来很有效并且有帮助,但是仍然是一种解决方法。 As long as the docs state that GIF is supported format, even if discouraged, it is expected to work. 只要文档声明支持GIF格式,即使不鼓励使用,也可以正常使用。

Still, most simple GIF usually are much more smaller in footprint compared to their (optimized) PNG version. 尽管如此,大多数简单的GIF相比其(优化的)PNG版本通常占用的空间要小得多。 For me, this bug-forced conversion adds another 200k, thats 20% of the whole app size. 对我来说,这种强制转换的转换又增加了200k,占整个应用程序大小的20%。 Some developers still care about the apk footprint. 一些开发人员仍在乎apk的足迹。

To make the answer complete, so others may find it: 为了使答案完整,其他人可能会找到答案:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM